Understanding the !DOCTYPE Tag

Document type(!DOCTYPE) tag specifies how the browser is to interpret the HTML Code. Currently there are seven !DOCTYPE's in HTML 4.01 / XHTML 1.0 / XHTML 1.1 . Here is a list of them all:

HTML 4.01

HTML 4.01 Strict

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

HTML 4.01 Transitional

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

HTML 4.01 Frameset

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

XHTML 1.0

XHTML 1.0 Strict

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

XHTML 1.0 Transitional

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

XHTML 1.0 Frameset

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

XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

You will see there is Strict, Transitional and Frameset doctypes for both HTML 4.01 and XHTML 1.0 (XHTML 1.1 only has one doctype).

What is the difference between Strict, Transitional and Frameset doctypes?

Strict doctype

The strict doctype is as the name says, strict. If you use this doctype your web browser will switch to 'standards mode' i recommend using the strict doctype. As the browser will process your code much better(if your code is valid). In the strict doctype certain attributes and tags are invalid.

Transitional doctype

This doctype is the 'non-standards' doctype. It will switch the browser to 'non-standards mode'. I recommend not using this doctype, unless you need to use some of the attributes or tags that are invalid in the strict doctype.

Frameset doctype

The frameset doctype is used when frames are used on a page. Not many people use frames now-a-days, and sites look much better without frames, i recommend not using frames at all. Unless you have a special purpose for them.

Valid code?

You may be thinking 'how do i know whether my code is valid or not?'. Well validating your code is quite simple, it can be done online on the following sites:


Once you are on the site, enter your pages URL or use the browse option to validate off your computer. When you have submitted it, a page will come up with all the errors your page has and a description of how to fix them. If your page has no errors, well done.

Comments


Warning: include(comment.php) [function.include]: failed to open stream: No such file or directory in /home/htmlsnet/public_html/web-articles/understanding-the-doctype-tag.html on line 90

Warning: include(comment.php) [function.include]: failed to open stream: No such file or directory in /home/htmlsnet/public_html/web-articles/understanding-the-doctype-tag.html on line 90

Warning: include() [function.include]: Failed opening 'comment.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/htmlsnet/public_html/web-articles/understanding-the-doctype-tag.html on line 90