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> |
Note: A common mistake with nested lists, is to forget that the inside list must be within <li> and </li> tags.
This is wrong:
<ul> <li>Ice Cream</li> <li>Frozen Yogurt <ul> <li>Strawberry Frozen Yogurt</li> <li>Vanilla Frozen Yogurt</li> </ul> <li>Toppings</li> </ul> |
This is correct:
<ul> <li>Ice Cream</li> <li>Frozen Yogurt <ul> <li>Strawberry Frozen Yogurt</li> <li>Vanilla Frozen Yogurt</li> </ul> </li> <li>Toppings</li> </ul> |
Notice </li> tag after the </ul> tag in the "correct" code example.
Non-empty elements must have a closing tag.
This is wrong:
<p>Welcome to Ron's Store <p>Please buy more stuff! |
This is correct:
<p>Welcome to Ron's Store</p> <p>Please buy more stuff!</p> |
Use self-closing tags for <br> <hr>, etc.
This is wrong:
|
This is correct:
|
Tag names and attributes must be in lower case.
This is wrong:
<BODY> <P>Welcome to Ron's Store</P> </BODY> |
This is correct:
<body> <p>Welcome to Ron's Store</p> </body> |
All XHTML elements must be nested within the <html> root element. Child elements must be in pairs and correctly nested within their parent element.
The basic document structure is:
<html> <head> ... </head> <body> ... </body> </html> |