Web Standards Primer

Emily Lewis

What Are Web Standards?

The Holy Grail

It All Starts With Valid Markup

Choosing a DOCTYPE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Why Validate?

Validation Tools

* CSS should be valid too!

Semantics = Meaning

Semantic code means your content is marked up with elements that convey meaning and provide context:

The Good

  1. <h1>About Emily Lewis</h1>
  2. <p>I'm a web designer living in Albuquerque, New Mexico. I specialize in hand-coding semantic (X)HTML and CSS, designing accessible web sites, and writing and optimizing web content.</p>
  3. <ul>
  4.    <li><a href="http://twitter.com/emilylewis">Twitter</a></li>
  5.    <li><a href="http://flickr.com/photos/eplewis">Flickr</a></li>
  6.    <li><a href="http://www.facebook.com/profile.php?id=795097355">Facebook</a></li>
  7. </ul>

The Bad (and Ugly)

  1. <div class="heading">About Emily Lewis</div>
  2. <div class="paragraph">I'm a web designer living in Albuquerque, New Mexico. I specialize in hand-coding semantic (X)HTML and CSS, designing accessible web sites, and writing and optimizing web content.</div>
  3. <a href="http://twitter.com/emilylewis" class="list">Twitter</a>
  4. <a href="http://flickr.com/photos/eplewis" class-"list">Flickr</a>
  5. <a href="http://www.facebook.com/profile.php?id=795097355" class="list">Facebook</a>

Both Are Valid, So Why Does It Matter?

Don't Forget About the CSS

#secondaryNav rather than #leftColumn

* More of a best practice and sometimes can't be avoided

Keeping Everything Separate

Great Presentation With Valid, Semantic CSS

The Good = Lightweight XHTML

  1. <h1 id="logo">Website Logo</h1>
  2. <ul id="primaryNav">
  3.    <li><a href="#">Menu link</a></li>
  4.    <li><a href="#">Menu link</a></li>
  5.    <li><a href="#">Menu link</a></li>
  6.    <li><a href="#">Menu link</a></li>
  7. </ul>
  8. <div id="content">
  9.    <h2>Page Heading</h2>
  10.    <p>Introductory paragraph of content. Introductory paragraph of content. Introductory paragraph of content. Introductory paragraph of content.</p>
  11.    <p>Secondary paragraph of content. Secondary paragraph of content. Secondary paragraph of content. Secondary paragraph of content.</p>
  12.    <p>Tertiary paragraph of content. Tertiary paragraph of content. Tertiary paragraph of content. Tertiary paragraph of content. </p>
  13. </div>
  14. <div class="clearer"></div>

The Good = External CSS

  1. body {font: small Geneva, Arial, sans-serif;color: #000;}
  2. h2 {font-size: 88%;color: #bb0e5d;}
  3. p {font-size: 80%;margin:0 0 10px 0;}
  4. clearer {clear: left}
  5. #logo {font-size: 95%;color: #bb0e5d;background: #777d6a;height: 100px;padding: 10px;}
  6. #primaryNav {list-style-type: none;font-size: 85%;background: #999f8e;float: left;width: 100px;padding: 10px;}
  7. #content {background: #d2d8c7;float: left;padding: 10px;}

The Bad (and Really Ugly) = Tag Soup, Code Bloat

  1. <table width="100%" style="height: 100%;" cellpadding="10" cellspacing="0" border="0">
  2.    <tr>
  3.       <td colspan="2" style="height: 100px;" bgcolor="#777d6a">
  4.          <font face="geneva,arial" size="4" color="#bb0e5d"><b>Website Logo</b></font></td>
  5.    </tr>
  6.    <tr>
  7.       <td width="20%" valign="top" bgcolor="#999f8e">
  8.          <font face="geneva,arial" size="2" color="#000000"><a href="#">Menu link</a></font><br />
  9.          <font face="geneva,arial" size="2" color="#000000"><a href="#">Menu link</a></font><br />
  10.          <font face="geneva,arial" size="2" color="#000000"><a href="#">Menu link</a></font><br />
  11.          <font face="geneva,arial" size="2" color="#000000"><a href="#">Menu link</a></font>
  12.       </td >
  13.       <td width="80%" valign="top" bgcolor="#d2d8c7">
  14.          <font face="geneva,arial" size="3" color="#bb0e5d"><b>Page Heading</b></font><br /><br />
  15.          <font face="geneva,arial" size="2" color="#000000">Introductory paragraph of content. Introductory paragraph of content. Introductory paragraph of content. Introductory paragraph of content.</font><br />
  16.          <font face="geneva,arial" size="2" color="#000000">Secondary paragraph of content. Secondary paragraph of content. Secondary paragraph of content.</font><br />
  17.          <font face="geneva,arial" size="2" color="#000000">Tertiary paragraph of content. Tertiary paragraph of content. Tertiary paragraph of content. Tertiary paragraph of content.</font>
  18.       </td>
  19.    </tr>
  20. </table>

Unobtrusive JavaScript for Progressive Enhancement

The Don'ts:
Inline event handlers in (X)HTML elements
javascript: in links (<a>)
Inline JavaScript blocks anywhere in your web pages
Proprietary DOM (i.e., document.layers, document.all)
The Dos:
Keep JavaScript in external files and apply events to elements from there
Apply JavaScript event handlers to elements that already have built-in functionality for communicating (i.e., <a>, <input type="submit">)
Ensure complete functionality even if JavaScript is disabled
Standardized DOM (i.e., getElementById, getElementsByTagName, getAttribute)

An Aside: WYSIWYGs

WYSIWYG editors = Frontpage, DreamWeaver, Contribute, etc.

Worth Repeating: The Big Picture Benefits

Reduced Bandwidth
Shared resources (JavaScript, CSS) are cached
Typically smaller file sizes
Easier Maintenance
Easier to change one CSS or JavaScript file than hundreds of pages of markup
Easier to hand off work if best practices are followed
Minimal need for development to suit multiple devices (mobile, print, etc.)
Forward compatibility
Easier to troubleshoot

Worth Repeating: The Big Picture Benefits

Improved Accessibility
Greater ease–of–use for people with disabilities of all types
Browser independent
Progressive enhancement
Better SEO
"Indexable" content for faster page spidering
Improved search engine rankings

The Little Picture Benefits

Waxing Philosophic

That said …

Standards in Action: This Presentation

Must-Have Resources

Must-Have Resources