June 17, 2012

Declaring DOCTYPE for HTML and XHTML


A DOCTYPE defines the various characters of a webpage, which helps the web browser to choose what the coder tells. Declaring a DOCTYPE is very important for any webpage, and without it there may be numerous differences across various browsers.

HTML 4.01 Strict:

This type of DTD allows only tags that are recent and doesn't allow tags that are deprecated. These tags are not so common and should be used only to create a standard declaration.


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

HTML 4.01 Transitional:

A transitional doctype is the most common type and it allows the deprecated tags too to fill the code and that is of a great advantage and most developers use this kind of DTD to their webpage.


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

HTML 4.01 Frameset:

This is same as the transitional doctype, but the only difference is that it allows additional frameset in a webpage.


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

Today, people use XHTML instead of HTML because its a little more than a newer implementation of HTML with little changes and it also gives a much more standardization.

XHTML 1.0 Strict:

Similar to the HTML Strict DTD declaration, this one also doesn't allow deprecated tags into the code.


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

XHTML 1.0 Transitional:

This one has a slight modification than the Strict declaration by allowing the deprecated tags, so that coders can also choose the old tags.


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

XHTML 1.0 Frameset

This allows the deprecated tags and it is just similar to the transitional doctype declaration and with an additional feature of allowing frameset in a page.


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

No comments:

Post a Comment