DOCTYPE Example

The DOCTYPE declaration

The DOCTYPE declaration is optional in html but highly recommended. Note that in XHTML, you must insert one for your page to validate. The DOCTYPE declaration's purpose is to tell browsers what to expect and tell validators what to compare your page to when validating.

Here's a DOCTYPE example :

<!DOCTYPE HTML PUBLIC
"//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

This DOCTYPE example is a traditional HTML DOCTYPE. If you want to create a standard HTML document with code learned in this tutorial, use the above DOCTYPE example.

Here's the rest of the DOCTYPE declarations and a short explanation of each:

HTML 4.01 DOCTYPE declarations

HTML 4.01 Transitional DOCTYPE example:

<DOCTYPE HTML PUBLIC
"//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

Use the HTML transitional DOCTYPE declaration if you plan on having styles (explained later in the tutorial) directly into your HTML. If you plan to strictly use an external CSS stylesheet (again, explained later), you could try the next DOCTYPE.

HTML 4.01 Strict DOCTYPE example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

To use the HTML strict DOCTYPE declaration, you must have very clean HTML. You must also have all your styles stored on an external stylesheet.

HTML 4.01 Frameset DOCTYPE Example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

Use the HTML frameset declaration if you want to use frames. It's the exact same thing as a transitional DOCTYPE. Instead of using the body element, replace it with the frameset element (this will be seen later in the tutorial). I highly suggest you not use frames though. The frames often get all split up in the search engines (I will cover this later in the tutorial when learning how to make the frames)

XHTML 1.0 DOCTYPE declarations

XHTML 1.0 Transitional DOCTYPE example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Use the XHTML transitional DOCTYPE declaration if you want an XHTML page with the same conditions as the transitional HTML DOCTYPE.

XHTML 1.0 Strict DOCTYPE example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Use the XHTML strict DOCTYPE declaration if you want an XHTML page with the same conditions as the strict HTML DOCTYPE. Store your styles in an external stylesheet.

XHTML 1.0 Frameset DOCTYPE Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Use the XHTML frameset DOCTYPE declaration if you want an XHTML page with the same conditions as the Frameset HTML DOCTYPE.


Back
Name of the page
Next
Head and Body tags