Page 1 of 1
What's the doctype for?
Posted: Sun Oct 04, 2009 3:32 pm
by JellyFish
I'm not asking this in a noob way, but rather a rational way. What purpose does the doctype serve other then specifying what version of html you are using? Why did the standards go this way; with this approach? Why didn't the standards just add a version attribute to the html element?
Code: Select all
<html version="5">
<head>
...
</head>
<body>
...
</body>
<html>
Every new version of html would just require that you change the number in the version attribute. Why did the standard go this way:
Code: Select all
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
The doctype for html 5 is so ambiguous. The doctype is html? Which version of html? They over-simplified IMO. It should have been:
Other wise, what would html 6's doctype look like? If they just added a number to the doctype, the next version of html would be more consistent:
But why even have a doctype? Why not just a version attribute, at least then why would have a/another reason for the html tags being wrapped around the entire document.
So really, what's the rational behind the doctype in the first place? Does anyone here on these forums know? Could anyone tell me?
Thanks for reading.
Re: What's the doctype for?
Posted: Sun Oct 04, 2009 3:54 pm
by jackpf
I think the doctype should also link to a DTD to validate the page against.
So yeah... that may be why

Re: What's the doctype for?
Posted: Sun Oct 04, 2009 3:58 pm
by JellyFish
jackpf wrote:I think the doctype should also link to a DTD to validate the page against.
So yeah... that may be why

But there is no DTD in HTML5's doctype.
Re: What's the doctype for?
Posted: Sun Oct 04, 2009 4:12 pm
by jackpf
Oh...I guess it's just XHTML that specifies a DTD then...
I'm not sure then.

Re: What's the doctype for?
Posted: Mon Oct 05, 2009 1:25 am
by JellyFish
What's a DTD even for? Do things really need to be as complicated as that? I really dislike the fact that I don't have the ability to jot out complete standard (X)HTML from my memory. I think things need to be more simple. Saying the doctype is html when the first element of the document is html is kind of redundant. So really, why not just a version attribute? I guess this is a question for WHATWG.
Re: What's the doctype for?
Posted: Mon Oct 05, 2009 5:39 am
by jackpf
Well, you should really have already told the browser what the document is with a content-type header...so it will understand the <doctype>. I always thought the doctype was to specify a DTD to validate the page against...because obviously XHTML is a variation of XML...and XML accepts pretty much any tags, which is why it needs a DTD to be validated against.
I guess maybe HTML doesn't need to be validated against anything...since syntax errors don't really matter.
This is all just hypothetical though. Don't take my word for it

Re: What's the doctype for?
Posted: Mon Oct 05, 2009 10:08 am
by pickle
The purpose of specifying a doctype is basically to tell the browser what dialect you're using. Most engines have 2 modes - standards mode and "try to get it to display" mode. If you specify a doctype, the engines go into standards mode & display the page with a specific set of rules. This is usually faster to render, and provides for better cross-browser compatibility.
Imagine you knew you were going to have a conversation with someone who speaks English. There are a lot of accents out there. If you're expecting to talk to someone from your hometown, but hear a really rough Australian accent, it might take a bit of work to understand. If you knew they were going to speak with an Australian accent to begin with, you'd have a better chance of completely understanding them. Browsers are the same way - if you specify which dialect you're using, they'll have a better chance of understanding the document completely.
Re: What's the doctype for?
Posted: Wed Oct 07, 2009 12:33 pm
by wiseguy12851
html is moving towards uniform like XML and XHTML therefore the websites who do not use uniform coding like HTML are still being applied uniform-like tags. The doctype is mandatory for XHTML and is required to be followed by a DTD. To make it easier on current browsers and new browsers HTML is uniformed to also include a doctype so programming browser software and updates can be easier and less chance of bugs.
BY THE WAY -------------------
the doctype you included above is incorrect and is suppose to include a DTD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd"> --- HTML Strict
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"> --- Transitional
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "
http://www.w3.org/TR/html4/frameset.dtd"> --- Frameset
As conformed by the W3C
Re: What's the doctype for?
Posted: Fri Oct 09, 2009 2:03 pm
by JellyFish
wiseguy12851 wrote:html is moving towards uniform like XML and XHTML therefore the websites who do not use uniform coding like HTML are still being applied uniform-like tags. The doctype is mandatory for XHTML and is required to be followed by a DTD. To make it easier on current browsers and new browsers HTML is uniformed to also include a doctype so programming browser software and updates can be easier and less chance of bugs.
What do you mean by uniform; I don't know what you mean by that?

Could you explain what you mean by uniform and uniform coding, because I'm not familiar with that word in this context?
Actually the doctype I was giving was the
HTML5 doctype not HTML4. What I'm discussing in this thread, is about the HTML5 doctype. Sense the HTML5 doctype really doesn't say anything more then "HTML", not even "HTML5", it's just saying it's html. Sense it's so ambiguous, why do we even need it? If I were standardizing things, I would simply add a version attribute and be done with it. Why do we need a DTD? Or why would we have to write it out in our code? Why can't it be the browser's job to check against the correct DTD or what ever you do with a DTD?
Re: What's the doctype for?
Posted: Fri Oct 09, 2009 9:53 pm
by wiseguy12851
Uniform can loosely be referenced as "by the book" and similarity. Ideally is would be less catastrophic for browser programming if all pages had similar tags, which in this case is doctype, It would be easier for a programmer to program a web browser to look for a specific tag automatically rather than determine if the page will have it or not thus de-complicate a ton of issues and allow for more sites to safely transition over to advanced coding like advanced CSS without worry on the client end.
so the HTML tag you described above is overlooked by older browsers and greatly aids new browsers, as well as any mid-transitions. XML and XHTML both require it so add it to HTML as well to get uniform and simplicity without breaking backwards compatibility.