Hey. I wanna know whats !DOCTYPE that I always find in styling articles and CSS tutorials?
What is it? Should it be at the beginning of HTML documents?
Is it wrong to make it in lower case (!doctype)?
Why is that exclamation mark there?
Thanks in advance :)
PS: Please dont give me links 'cause a lot of websites arent accessible here
doctype defines the document type
the appropriate doctype for the code of the files ensures the page displays and functions as intended
precisely as written
So why is that exclamation mark? Also why do we write that website in it:
I know it is the world wide web consortium but does the browser start to get its way of parsing HTML from that website when we write that website address??
When authoring document is HTML or XHTML, it is important to Add a Doctype declaration. The doctype declaration must be exact (both in spelling and in case) to have the desired effect, which makes it sometimes difficult. To ease the work, below is a list of recommended doctype declarations that you can use in your Web documents.
(X)HTML Doctype Declarations List
Strict <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Transitional <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Frameset <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
Strict (quick reference) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Transitional <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Frameset <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1.1 - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
XHTML Basic 1.1 (quick reference): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
HTML 5 [NOT a standard yet] <!DOCTYPE HTML>
MathML Doctype Declarations
MathML 2.0 - DTD: <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">
MathML 1.01 - DTD: <!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">
Compound documents doctype declarations
XHTML + MathML + SVG - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
XHTML + MathML + SVG Profile (XHTML as the host language) - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
XHTML + MathML + SVG Profile (Using SVG as the host) - DTD: <!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
Optional doctype declarations
Beyond the specificities of (X)HTML processing, Doctype declarations in XML languages are only useful to declare named entities and to facilitate the validation of documents based on DTDs. This means that in many XML languages, doctype declarations are not necessarily useful.
The list below is provided only if you actually need to declare a doctype for these types of documents.
SVG 1.1 Full - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
SVG 1.0 - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
SVG 1.1 Basic - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">
SVG 1.1 Tiny - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
Historical doctype declarations
The doctype declarations below are valid, but have mostly an historical value — a doctype declaration of a more recent equivalent ought to be used in their stead.
HTML 2.0 - DTD: <!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
HTML 3.2 - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
XHTML Basic 1.0 - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
There is not just one type of HTML, there are actually many: HTML 4.01 Strict, HTML 4.01 Transitional, XHTML 1.0 Strict, and many more. All these types of HTML are defined in their respective W3C specifications, but they are also defined in a machine-readable language specifying the legal structure, elements and attributes of a type of HTML.
Such a definition is called a "Document Type Definition", or, for short, DTD.
Some tools which process HTML documents might need to know which DTD an (X)HTML document uses: this is why each (X)HTML document needs, at the beginning, a DTD declaration, such as:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Given its syntax, the DTD declaration is often called, for short, "Doctype".
Why specify a doctype? Because it defines which version of (X)HTML your document is actually using, and this is a critical piece of information needed by some tools processing the document.
For example, specifying the doctype of your document allows you to use tools such as the Markup Validator to check the syntax of your (X)HTML. Such tools won't be able to work if they do not know what kind of document you are using.
But the most important thing is that with most families of browsers, a doctype declaration will make a lot of guessing unnecessary, and will thus trigger a "standard" rendering mode.
Why the bang, why uppercase? the format was decided upon by the standards group same as all other (x)html elements
officially that url points to a web address, reality the browser interprets it from internally stored data,
older browsers and new standards, there is the chance the browser can pull information on how to display the code from the web address
the dtd contained in the attachement can be read in any text editor and describes much of the standard in machine/human readable form
To add to what almostbob has said.
The doctype is the set of rules you are telling the browser you are using to create the page. Change the doctype, change the rules. - doc
Thank you almostbob! You're the best.. I really appreciate that
And thank you Arkinder too