HTML » XHTML validation

XHTML is more stict and clean than HTML, but they're almost identical coding languages.
 
XHTML vs. HTML:

Doctype

The first code in a HTML page should be the doctype declaration! We have 3 different doctypes,
 
Strict should be used when the coding is really clean, no deprecated elements and no target attributes (in links for example), also, all formatting must be done in CSS, <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Transitional is the most commonly used doctype. You can use deprecated elements and target attributes, <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Frameset should be used if your page uses frames that divide the browser window into 2 or more frames, <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Root element

All tags must be within the root element <html>, like this, <html>
<head> Title here </head>
<body> Tags goes here </body>
</html>
No tags must fall outside of the root element!

Lowercase

All tags , their attributes and their values must be in lowercase!
 
Wrong, <P Class="Title"> Correct, <p class="title">

Tags order

Wrong, <p><b>Bold text</p></b> See how the p tag closes before the b tag does? This is wrong, since the b tag opened after the p tag.
 
Correct, <p><b>Bold text</b></p> <b><p>Bold text</p></b>

Closed tags

Every single tag must be closed, also the empty tags! <h1>Header</h1>
<p>Paragraph</p>
 
Empty tags:
<br />
<hr />
<img href="url" alt="" />
Notice the space before the / in the empty tags

Image attribute

All image tags should contain the alt="" attribute, <img href="url" alt="" />

Quoted attribute values

All attribute values must be quoted with doubble quotes: ", <div id="title">Title</div>

Now validate!

XHTML page: Validate your page!