In HTML, some elements can be improperly nested within each other, like this:
<b><i>This text is bold and italic</b></i>
In XHTML, all elements must be properly nested within each other, like this:
<b><i>This text is bold and italic</i></b>
//XHTML elements must always be closed
//this is wrong
<p>This is a paragraph
<p>This is another paragraph
//this is correct
<p>This is a paragraph</p>
<p>This is another paragraph</p>
//empty elements must also be closed
//this is wrong
A break: <br>
A horizontal rule: <hr>
An image: <img src="happy.gif" alt="Happy face">
//this is correct
A break: <br />
A horizontal rule: <hr />
An image: <img src="happy.gif" alt="Happy face" />
//XHTML elements must be in lower case
//this is wrong
<BODY>
<P>This is a paragraph</P>
</BODY>
//this is correct
<body>
<p>This is a paragraph</p>
</body>
-
Must be properly nested.
-
Must always be closed.
-
Must be in lowercase.
-
XHTML documents must have one root element.
//XHTML attribute names must be in lower case
//this is wrong
<table WIDTH="100%">
//this is correct
<table width="100%">
//attribute values must be quoted
//this is wrong
<table width=100%>
//this is correct
<table width="100%">
//attribute minimization is forbidden
//wrong:
<input type="checkbox" name="vehicle" value="car" checked />
//correct:
<input type="checkbox" name="vehicle" value="car" checked="checked" />
-
Attribute names must be in lower case.
-
Attribute values must be quoted.
-
Attribute minimization is forbidden.