what does browser do upon DOCTYPE

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
in xhtml header:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

what does browser do upon DOCTYPE?should it issue a http get request
to w3 server?

can i put the dtd under my server for better performance?

Re: what does browser do upon DOCTYPE

Coonay wrote:

Quoted text here. Click to load it

In practice, it parses the DOCTYPE declaration (as above - not the document
type definition it refers to) and selects "Quirks Mode", "Almost Standards
Mode", or "Standards Mode" (which might be almost standard on some browsers)
according to certain more or less confused and even perverse rules. See

Quoted text here. Click to load it

No, it is not required or even recommended to do so. It might of course, but
it doesn't. It wouldn't be useful, since it is much more efficient to have
the DTD built in into the browser, more or less (if parsing is to be based
on the DTD).

Quoted text here. Click to load it

It woudn't matter, since the DTD is not read. On the other hand, changing
the URL might (or might not) affect DOCTYPE sniffing - who knows?

But if browsers actually read the DTD, then your approach would be much
_less_ efficient. Browsers would surely get the DTD faster from the W3C
server than most other servers around. And since the W3C resource would be
retrieved very often, it would be cached efficiently. So using a local DTD
would be useful (at most) to people very near to you (by Internet metrics).

Yucca, http://www.cs.tut.fi/~jkorpela/

Re: what does browser do upon DOCTYPE

On Thu, 12 Mar 2009, Coonay wrote:

Quoted text here. Click to load it

But why should you use XHTML 1.0 Transitional?

When you write something new, you should go for "Strict" -
either "HTML 4 Strict" or "XHTML 1.0 Strict".

When you have some older pages, just keep them as HTML 4 Transitional.
There is absolutely no point in converting them to XHTML Transitional.

In memoriam Alan J. Flavell
http://www.alanflavell.org.uk/charset /

Re: what does browser do upon DOCTYPE

Quoted text here. Click to load it

This piece of the document is the "doctype declaration", and it refers
to a "doctype". If you're getting involved in the details, this will
start to make a difference you should pay attention to.

Years ago SGML, the foundation of HTML, had the notion of supporing
many different sorts of document using many different doctypes. The
tools were generic SGML tools, not application-specific, and they
needed to obtain a copy of the doctype before they could work with the
documents that used it.

With HTML, there are only a handful of doctypes. We rarely work with
HTML using generic SGML tools, but instead we use web browsers that
_only_ handle HTML. Rather than "using" a doctype as SGML intended,
these browsers have these well-known HTML doctypes embedded within
them (or at least they have embedded behaviours based on that
assumption). So a HTML web browser is less flexible than an SGML tool,
but it doesn't need to download a doctype.

The doctype declaration (the thing in a web page that specifies which
doctype is used) is important. It can have several forms, all of which
still refer to the same doctype. You might think these would work int
he same way and have the same overall result, but they actually make a
very big difference. The "quirks mode" (web search for it) behaviour
often varies not only on the doctype used, but on the precise doctype
declaration used to specify it. Henri Sivonen's web site has a good
article on this.

As a general rule, always use the HTML 4.01 Strict doctype with a
doctype declaration that forces "standards mode" rendering (see
Sivonen). Don't use either XHTML or Transitional unless you know why
and you need to. There are valid reasons for either, but if you
genuinely _ought_ to be doing this, you ought to know why you're doing

Quoted text here. Click to load it



There are times when people use a custom doctype (search this
newsgroup) to get specific behaviours. However this is a little
unpredictable in behaviour. Although it's a legitimate SGML practice,
the web-based and HTML practices that have sprung up since mean that
some tools and browsers won't pay attention to it.

Re: what does browser do upon DOCTYPE

Andy Dingley wrote:

Quoted text here. Click to load it

Ignoring the frameset abortion, I get:

HTML 2.0
    "-//IETF//DTD HTML 2.0 Strict Level 1//EN">

HTML 3.2
    "-//IETF//DTD HTML 3.2 Strict//EN">

HTML 4.01
    "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd ">

HTML 4.01 Transitional
    "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd ">

ISO HTML (https://www.cs.tcd.ie/15445/UG.HTML )
   "ISO/IEC 15445:2000//DTD HyperText Markup Language//EN">

HTML 5.0
<!DOCTYPE html>

Re: what does browser do upon DOCTYPE

Quoted text here. Click to load it

Is there some significance to the fact that some of these DTDs have
"html" written in upper, and some in lower, case?

If so, what is it?

Is, for example, the following 4.01-specified DTD in some way wrong
for having the "html" (the one that's just to the right of "<!DOCTYPE")
written in lower-case instead of upper-case?

        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd ">

Re: what does browser do upon DOCTYPE

talented rj broadcast on comp.infosystems.www.authoring.html:

Quoted text here. Click to load it

The thing after DOCTYPE tells what element contains your document.

<!DOCTYPE foo ...>

Quoted text here. Click to load it

When case is significant in tags (look at NAMECASE in the sgml declaration
for the dtd; if GENERAL NO, case is significant - as in the xhtml dtds; if
GENERAL YES, case is not significant - as in html 4.* dtds) this must match
exactly the tag that contains your document.

Quoted text here. Click to load it

in HTML 4.01 there is no difference really.  The sgml declaration for

         <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
             "http://www.w3.org/TR/html4/strict.dtd ">

is valid, and so is:

         <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
             "http://www.w3.org/TR/html4/strict.dtd ">

and so is:

         <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
             "http://www.w3.org/TR/html4/strict.dtd ">

and in fact the html tags are optional (in which case the parser will
simply infer that your document is contained in html.

Note the part after PUBLIC must be the ID of a dtd and must match exactly,

PUBLIC "-//W3C//DTD HTML 4.01//EN" is the name of a W3C dtd but

PUBLIC "-//W3C//DTD html 4.01//EN" is not defined.

In xhtml, case in tags is not general, so it must be html in the
DOCTYPE and the html tags are not optional, so they must be <html> ...
</html> and not <HTML> ... </HTML> and must be entered explicitly.

Now some people, including me, want to use html 4.01, but want their
documents to be very similar to xhtml, so we check our html against a
dtd with sgml declaration that is more like xhtml.

         <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
             "http://www.w3.org/TR/html4/strict.dtd ">
         <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
             "http://www.w3.org/TR/html4/strict.dtd ">

both will work with "official" HTML 4.01, only the lowercase version will
work when faked into checking against a more xhtml-like dtd.

        Lars Eighner <http://larseighner.com/ usenet@larseighner.com
            68 days since Rick Warren prayed over Bush's third term.
   Obama: No hope, no change, more of the same. Yes, he can, but no, he won't.

Site Timeline