What for does one need doctype?

T

test

Hi everybody,

What for does one need to use doctype? I did not put this tag into my
HTML code and everything looks OK (besides that HTML-validator tells me
that my document is not valid). Can the absence of the doctype lead to
more significant problems?
 
C

Chaddy2222

Hi everybody,

What for does one need to use doctype? I did not put this tag into my
HTML code and everything looks OK (besides that HTML-validator tells me
that my document is not valid). Can the absence of the doctype lead to
more significant problems?
Well, in a lot of ways yes.
The document type decleration (DTD) tells the web browser what type the
document is and what set of rules to use when displaying the website.
As an example, when a half doc type is used, that validates, it gives
the browser some clue as to how to read or pass the source code of the
page, if a half doc type is used, the browser will use quirks mode,
even if the page validates, for a site to be in standards compliant
mode, it needs the full W3C identifyer.
While a page may look ok in your web browsers in full quirks mode, you
need to make sure your pages validate so they work on other devices
such as mobile phones.
It should also be noted that my site does validate, however when I do a
re-design soon I will be transfering the DTD to a strict DTD rather
then transitional.
 
J

Jukka K. Korpela

Chaddy2222 said:
The document type decleration (DTD) tells the web browser what type
the document is and what set of rules to use when displaying the
website.

No it doesn't. The OP will find better answers by looking at the group
archives at http://groups.google.com . The issue has been discussed so many
times that people are tired of it, so you mostly get answers from people who
didn't bother checking things out either. Formally, the DOCTYPE declaration
refers to a DTD, but browsers don't really even read the DTD.

The short answer is that by not using a DOCTYPE declaration exactly as
specified in HTML specifications, you probably throw Internet Explorer and
some other browsers into "quirks mode", which means intentionally broken
(nonstandard) mode of operation. Google for "DOCTYPE sniffing" if you need
the dirty details.
 
C

Chaddy2222

Jukka said:
No it doesn't.

<snip>
Yeah well, strictly speeking it doesn't however it does tell a web
browser how to render the page.


The issue has been discussed so many
times that people are tired of it, so you mostly get answers from people who
didn't bother checking things out either. Formally, the DOCTYPE declaration
refers to a DTD, but browsers don't really even read the DTD.
Yeah well, I believe I explained this in my previous post, however I
will admit I am still learning about issues to do with the DTD myself.
But most browsers will read the DTD, however some choose to ignore it,
depending on the browser and DTD used.
The short answer is that by not using a DOCTYPE declaration exactly as
specified in HTML specifications, you probably throw Internet Explorer and
some other browsers into "quirks mode", which means intentionally broken
(nonstandard) mode of operation. Google for "DOCTYPE sniffing" if you need
the dirty details.
Yes, I believe I did write something to that effect also.
 
T

Travis Newbury

What for does one need to use doctype? I did not put this tag into my
HTML code and everything looks OK (besides that HTML-validator tells me
that my document is not valid). Can the absence of the doctype lead to
more significant problems?

Depends if the page looks ok without it, and you don't care about
validation then you don't "need" it
 
S

Steve Pugh

Chaddy2222 said:
But most browsers will read the DTD, however some choose to ignore it,

No. No browser reads the DTD for HTML. IE doesn't, Firefox doesn't,
Opera doesn't, Safari doesn't, Lynx doesn't.
depending on the browser and DTD used.

Not unless you're talking about XML documents served as XML in which
case some browsers will fetch the DTD under some circumstances. But
that's irrelevant for HTML and for XHTML served as HTML.

Don't confuse the browsers' use of the doctype as a magic code to
switch rendering modes with anything to do with actually fetching and
reading the DTD referenced by the doctype.

Steve
 
A

Andy Dingley

Jukka said:
No it doesn't.

While Chaddy's answer is certainly partial (I too am too bored to
bother re-posting half of Google) in what way is it strictly "wrong" ?

Now these, especially the second, are a condemnation of browsers as
much as anything, but as empirical observations about how browsers
actually function, then what's wrong with them?


To the OP: Google search through c.i.w.a.h You'll learn more than you
probably wanted to know. You might even learn how to expand your
killfile as an idiot pruner (VK and the darling Andkon springs to mind)
 
J

Jukka K. Korpela

While Chaddy's answer is certainly partial (I too am too bored to
bother re-posting half of Google) in what way is it strictly "wrong" ?

It is wrong*) because it is contrary to actual facts. That is, neither the
document type declaration nor the DTD**) says such a thing, in principle or
in practice.

*) That is: incorrect, false. I don't know your definition for "strictly
'wrong'".

**) DTD = document type definition. "Chaddy2222" apparently does not know
the difference between this and the document type declaration. This is quite
common, but it still makes her or him unqualified to give assistance on
matters like this.
 
A

Andy Dingley

Depends if the page looks ok without it, and you don't care about
validation then you don't "need" it

Totally the wrong attitude.

Pages, even the worst, rarely "look wrong" for their original author, or
else they'd fix them. The point about validation is that it's objective,
so that those of us using vaguely standards-aware browsers can still
read pages that were authored by IE-users.

Of course pathological use of incredible <font> sizes and absolute
positioning can still break anything that doesn't have the exact screen
resolution of a WebTV, but that's trailer parks for you...
 
A

Andy Dingley

It is wrong*) because it is contrary to actual facts. That is, neither the
document type declaration nor the DTD**) says such a thing, in principle or
in practice.

OK, now I see your point (to some extent). The DTD clearly doesn't tell
the browser anything because it doesn't even get loaded.

So how would you feel about this:
"The document type declaration (*) tells the web browser what type
the document is and what set of rules to use when displaying the
website."

What's wrong with that? I'm pretty pedantic, but I can't pick a hole
in that without stretching the meaning of "type" almost to breaking
point. Commonplace browsers _do_ categorise the content offered, they do
this according to rules that do involve the doctype, and they do vary
their rendering behaviour on the basis of this.

Secondly, what might you replace "*" with ? "Doctype" is the
colloquial argot for it, but would you agree with that?
 
C

cwdjrxyz

Hi everybody,

What for does one need to use doctype? I did not put this tag into my
HTML code and everything looks OK (besides that HTML-validator tells me
that my document is not valid). Can the absence of the doctype lead to
more significant problems?

You have received several answers. Perhaps it is now time for an
example. I slightly modified a DynamicDrive script for someone asking
for a text mousetrail effect. Viewed with Firefox, the script would
work at DynamicDrive, but not when I put it on an html 4.01 strict page
with the proper Doctype. I found the script would work if you used no
Doctype as DynamicDrive did, or if you used the proper Doctype for html
4.01 transitional. Keep in mind that this is rather old script that
still includes Netscape 4 support. This type of effect is not of much
interest to me, but to each his own. If you do not like the effect, the
complaint department is at DynamicDrive! The slight modifications
mentioned that I made were just a few things to make the code validate
at W3C.

First view http://www.cwdjr.net/text/mousetail.html . This works on any
browser I have if script is turned on. The Doctype is for html 4.01
transitional. Next view http://www.cwdjr.net/text/mousetailStrict.html
.. This is exactly the same code as for the first page except that it
uses the Doctype for html 4.01 strict. What you will see for the strict
version depends on the browser you use. The page works properly only on
my Opera 8.54 and Netscape 4.8 browsers. It does not work properly on
my Firefox 1.5.0.3, IE-6, Netscape 8.0.4, or Mozilla 1.7.11 browsers,
and the letters of the text stay fixed in the upper left corner of the
screen.

Even if one's standard is only that the page works properly, I think
this example shows that, at least in a few cases, use or nonuse of a
Doctype can change how the page views, or if the page works at all. I
have not had time to see just what produces the strange response seen
on these examples, and since I do not use this code myself, I am
unlikely to waste time on the details of it.
 
T

Travis Newbury

Andy said:
Totally the wrong attitude.

I was not commenting on if it were right or wrong, I only answered the
op's question "do I need it?"

and the answer is no you don't "need" it.
 
J

Jukka K. Korpela

Andy Dingley said:
OK, now I see your point (to some extent).

I'm afraid you don't. Either the statement was correct, or it wasn't. If it
were correct, the person who presented it, or someone else, could have given
arguments for it. I don't need to disprove it; you need to prove it, and you
cannot.
The DTD clearly doesn't
tell the browser anything because it doesn't even get loaded.

That's actually irrelevant, though it might make the point clearer for
psychological reasons. The DTD is a formal description of markup syntax,
nothing more, nothing less. It says absolutely nothing about the meaning of
any element, still less how it should be processed. Besides, the original
question was about "doctype", which commonly means document type declaration
( said:
So how would you feel about this:
"The document type declaration (*) tells the web browser what type
the document is and what set of rules to use when displaying the
website."

What's wrong with that?

It's simply incorrect. (It's even more incorrect than you intended; you
wrote "website" though you meant "web page".)
Commonplace browsers _do_ categorise the content offered,

That does not make a document type declaration tell them anything.

You can compare this with a situation where a server sends some data to a
browser, declaring, in HTTP headers, the data to be plain text, text/plain.
Some browsers are known to look at the last part of the URL, or the start of
the actual content of the data, and decide to treat the data as an HTML
document, text/html. This is clearly a violation of the protocol, and
authors may need to take appropriate actions to avoid it, so they may need
information about this misfeature. But it would be incorrect and
inappropriate to say, for example, that a URL ending of ".htm" or data
content starting with "<html>" tells the web browser what type the document
is and what set of rules to use when displaying the
website.

If you think that, for example, the document type declaration
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
really tells the web browser what type the document is and what set of rules
to use when displaying the website, then what _is_ this type and what _are_
these rules? The declaration is known to throw IE into "quirks mode", but
this is simply what the browser does, not based on anything that the
declaration tells. Besides, what the browser does hasn't even been publicly
documented by the vendor. (The existing material on this by Microsoft is
grossly incomplete, and they say that it is intentionally so.) If the
declaration really tells the browser to go to "quirks mode", should be blame
those browsers that do no such thing?
 
T

Toby Inkster

Travis said:
I was not commenting on if it were right or wrong, I only answered the
op's question "do I need it?"

Well, of course he doesn't *need* it, much like he doesn't *need* a
website to begin with. He could probably survive without one of his
kidneys too.
 
A

Andy Dingley

Jukka said:
That does not make a document type declaration tell them anything.

Ah, so it's "tell" you have the problem with

So let's try another draft

"The document type declaration (*) is used by the the web browser
to
identify what type of document it will treat it as, and what set of
rules
to use when displaying the web page."


I have to say though, although your comments have (as always) been
entirely accurate, you could have been a little more helpful by simply
giving an example of what you considered correct, rather than just
griping about what was wrong. Teaching isn't about how much you know,
it's about how much you can communicate.
 
J

Jukka K. Korpela

Ah, so it's "tell" you have the problem with

I don't think _I_ have a problem here. You seem to like to play with words.
This reminds me of some discussions concerning the concept "sex".
So let's try another draft

"The document type declaration (*) is used by the the web browser
to
identify what type of document it will treat it as, and what set of
rules
to use when displaying the web page."

I'm not particularly interested in euphemistic descriptions of doctype
sniffing. It's kludgery, it's not based on anything "telling" browsers
something, it's not identification, it's not about any rules (except in the
sense "whatever a browser does" - it's after all a program, i.e. an
algorithmic monster).
I have to say though, although your comments have (as always) been
entirely accurate, you could have been a little more helpful by simply
giving an example of what you considered correct, rather than just
griping about what was wrong.

I think I mentioned early in this thread that the topic has been discussed
before, and the OP could find answers in the archives. We've now gone
through some rounds and we are almost reaching the point where some previous
discussions have _started_. As usual, the thread will of course die rather
soon. Hence the recommendation to check past discussions rather than opening
an issue once again.
 
D

dorayme

Jukka K. Korpela said:
I don't think _I_ have a problem here. You seem to like to play with words.
This reminds me of some discussions concerning the concept "sex".


I'm not particularly interested in euphemistic descriptions of doctype
sniffing. It's kludgery, it's not based on anything "telling" browsers
something, it's not identification, it's not about any rules (except in the
sense "whatever a browser does" - it's after all a program, i.e. an
algorithmic monster).


I think I mentioned early in this thread that the topic has been discussed
before, and the OP could find answers in the archives. We've now gone
through some rounds and we are almost reaching the point where some previous
discussions have _started_. As usual, the thread will of course die rather
soon. Hence the recommendation to check past discussions rather than opening
an issue once again.

Just before it dies:

The browsers have rules, that is what algorithms are, they are
affected in some machine-like way by these doctype declarations.
It is not like they are a doc who is affected in different ways
by different patients, a doc might treat the same patient quite
different depending on how much Jim Beam he or she (ie. the doc)
drank the night before. How about "affected in a consistent way"
being a quality that each particular version browser tends to
have? How sober are these monsters?
 
T

Travis Newbury

Toby said:
Well, of course he doesn't *need* it, much like he doesn't *need* a
website to begin with. He could probably survive without one of his
kidneys too.

Speaking from experience I can attest that you can live with one kidney
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top