|Lessons||XHTML DOCTYPE declaration|
A valid XHTML document must have a DOCTYPE declaration. In addition html, head, title, and body elements must also be present.
A PROPER XHTML DOCUMENT:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<title>Title of document</title>
Body contents of the document.
You must be familiar with the html, head, title and body tags. The <!DOCTYPE> declaration refers to a Document Type Definition (DTD). A DTD specifies the rules for the markup language, so that the browsers can render the content correctly. This declaration is not an XHTML tag, on the other hand it is an instruction to the web browser about the version of the markup language the current page is written in.
Note: If you need to understand more about DTDs, you need to learn XML. For the XHTML learners it is sufficient to know that every XHTML document starts with the <!DOCTYPE> declaration.
Following is list of different XHTML dtds with a short description, so you could decide which dtd to use:
XHTML 1.0 Strict:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Contains all HTML elements and attributes, but NOT presentational or deprecated elements (like font). Framesets not allowed.
XHTML 1.0 Transitional:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Contains all HTML elements and attributes, also presentational and deprecated elements (like font). Framesets not allowed.
XHTML 1.0 Frameset:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
This DTD is the same as XHTML 1.0 Transitional, but allows the use of framesets.
This DTD is the same as XHTML 1.0 Strict, but allows you to add modules (A concept out of the scope of this tutorial).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
For more information about the different XHTML DTDs go to http://w3c.org
Next >>> Lesson No. 7: XHTML Common Mistakes