Skip to main content

DOCTYPE - Telling the Browser you know what you are doing.

The question remains.... How does a browser know that the page is XHTML? And, because there are several variations to XHTML how does the browser know which one is being used for each page.

For each XHTML document the DOCTYPE statement is added at the very top of the page. (It should be the very first line, followed by the <html> tag and then your block comments.)

Here is a copy of the DOCTYPE you should use on your pages:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Make certain it is the very first line. Later (in the Web Services: XML course) you will learn what each of this statement does. For now, just know that this statement is referring to a specific set of rules describing how each XHTML element will be used. It is this rule book that is used by validating programs so they know if your markup code is really following the rules or not.

There are other DOCTYPES.

One includes the word "strict" and does not allow any of the deprecated tags (deprecated means "soon to be obsolete") to be used on the page. This is a little too intense for this course and we will be using the more flexible transitional doctype.

There are also DOCTYPES for HTML instead of XHTML. This defeats the purpose because you want to validate your pages as XHTML markup, not the older HTML markup.

Here's a link to the W3C documentation showing all the available DOCTYPE statements. Do a find (CTRL F) for "3.1. Document Conformance"

Just remember that you want the DOCTYPE for: XHTML 1.0 Transitional