What is !DOCTYPE?
Not quite sure what !DOCTYPE is? Let me guide you through it.
By Bret Mette - November 1, 2007
!DOCTYPE Explained
!DOCTYPE is a top level tag that identifies which version of HTML or XHTML the document is using (often called DTD). HTML and XHTML come in a variety of versions, HTML 4.01 Strict, HTML 4.01 Transitional, XHTML 1.0 Strict to name a few.
What is DTD?
DTD stands for "Document Type Definition" and is a tool used by web browsers to determine what set of "rules" to use when reading the document. These "rules" are actually machine language that layout the legal structure, elements and attributes of a type of HTML or XHTML.
Why is !DOCTYPE Important?
The !DOCTYPE sets the mode the browser will use to interrupert the document. When the !DOCTYPE tag is omitted most browsers will attempt to guess at which language the document was written in. When forced to guess at the !DOCTYPE, the browser will render pages much slower and often in error. If the !DOCTYPE cannot be determined by the browser, it will default into "quirks" mode parsing. Quirks mode parsing is more forgiving, but can often render code in a way not intended by the author.
Example of HTML 4 !DOCTYPE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">