12.1. Choosing an HTML Flavor

As Web pages and browsers become more sophisticated, content creators are paying more attention to standards. For example, it's a sign of professionalism that a page declares the following in its markup:

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

That's a declaration that the page complies with the XHTML 1.0 Strict standard. You still find many sites supporting the previous standard, HTML 4.01, or no standard at all. Too many pages claim in their document type declaration (DOCTYPE) to support XHTML or HTML 4 but don't even come close when you dig into the markup.

XHTML 1.0 turns HTML markup into well-formed XML. The term well-formed means that the HTML code complies with XML rules such as these:

  • Self-closing tags: Like a fire door, tags must be self-closing such that the <img> tag must look like <img /> and <br> becomes <br />.

  • Close all tags: Tags that formerly stood alone like <p> and <li> are completed with </p> and </li>.

  • Quote attributes: Use id="myquotedid" instead of id=myunquoteid.

  • Consistent case: Keep the starting and closing tags in the same case. You can't use <A> for the opener and </a> for the closing tag. For the least hassle (and XHTML validation), just use lowercase everywhere. You can set that as an option in Visual Web Developer's HTML editor.

  • Use entities: Convert reserved characters to their special sequences (formally known as entities):

    < becomes &lt;

    > is &gt;

    & looks ...

Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.