Chapter 86. Validating Your Source Code
The World Wide Web Consortium (W3C) is so ape over on-spec coding that they offer to validate Web pages for free. If you want to see how well your site conforms to current standards and recommendations, this service might be of interest to you. Not only does the W3C's validator point out every last coding mistake or faux pas on a Web page, it gives you a lengthy report as to why, and it offers ways to correct the problems.
TIPIf you feel bad about receiving poor marks, just send the W3C's validator to the home page of a popular site such as Amazon or eBay. |
<a href="http://validator.w3.org/check/referer">
<img src="http://www.w3.org/Icons/valid-xhtml10" height="31"
</a>
</p>
To improve your page's chances, try these tips:Use lowercase letters for tag and attribute names.Put quotes around attribute values.Some attributes, like checked and selected, don't have values. Give them values equal to their attribute name, like this:
Observe proper nesting. That is, close nested tags in the reverse order that you open them. The first opened should be the last closed.If a tag doesn't have a closing version, like the img, br, and hr tags, include a slash before the closing angle bracket, like this:
<input type="checkbox" checked="checked" />
Nest lists within li elements, like this:
<img src="/image/library/english/10077_image.jpg" width="200" height="100" />
Don't embed scripts or style sheets. Link to external JavaScript or CSS files instead.If you must embed scripts or style sheets, remove any comments that hide the code from incompatible browsers.
<ol>
<li>List item 1</li>
<li>List item 2</li>
<li>
<ol>
<li>Nested list item 1</li>
<li>Nested list item 2</li>
</ol>
</li>
</ol>