Always Use Well-formed Code
For those not familiar with XHTML, the first thing to know is that all code should validate (according to the doctype) and be well-formed (a valid XML document). Here is a basic run down of the rules of well-formed XML as well as the key differences between XHTML and HTML.
All elements should be closed, e.g.
<br/>These are also acceptable:
<br> </br> <br />All non-empty elements should be closed:<p>Example Text</p>All elements must be properly nested:<em><strong>Example Text</strong></em>The alt attribute must be used for all images:<img src="image.png" alt="Image Description" />Text should appear within a block level element and not directly in the body: <body><p>Example Text</p></body>Inline elements should always nest with block level elements:
<h2><em>Example Text</em></h2>All attributes should appear within quotes:
<p class="names"/>All elements and attributes should use lowercase:
<p class="Sm">Example Text <hr noshade="true"/></p>
There are many online Web tools that you can use to validate your markup including the MobiReady Report and the W3C Validation service. There are also browser-based tools such as the HTML Validator Firefox Extension that can be used throughout the development cycle to keep an eye on your pages.



Sign in or register to reply.