<!DOCTYPE> declaration is the very first thing in your document, before the <html> tag. This declaration of the <!DOCTYPE> tells the browser which HTML or XHTML specification the document uses.
Everything in this declaration needs to match exactly (both spelling and case). If this is not entered into all your pages your browser will render your page in “Quirks Mode”, your page will not validate correctly with W3C Standards and you will spend more time getting your site to look perfect across all browsers then necessary.
N.B. Doctype is a shorted term for DTD.
Right, on with the different types of <!DOCTYPE> declarations:
HTML
There are 3 different DTD available to use under the HTML deleration: Strict, Transitional, and Frameset. Even though the below declerations are for HTML these are slowly been phased out in preference for the XHTML DTD below.
HTML 4 Strict DTD
Generally used when all formatting & styling are placed into the CSS file.
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
HTML 4 Transitional DTD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
HTML 4 Frameset DTD
This DTD is used if you are using frames for some reason??
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
XHTML
Again there are 3 XML document types: Strict, Transitional, and Frameset.
XHTML Strict DTD
Generally used when all formatting & styling are placed into the CSS file.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML Transitional DTD
This DTD supports everything found in XHTML 1.0 Strict, but also permits the use of a number of elements and attributes that are judged presentational such elements include <center>, <u>, <b> and <strike>.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML Frameset DTD
This DTD is used if you are using frames for some reason??
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
Hello World!!
</body>
</html>
You will notice that all the tags/elements are all in lower case, this is a must as you will not have a valid webpage otherwise.