What for does one need doctype?

Discussion in 'HTML' started by test@loctopus.com, May 23, 2006.

  1. Guest

    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?

    -----------------------
    Easy and free advertisement of your web-site!
    http://www.loctopus.com/
    , May 23, 2006
    #1
    1. Advertising

  2. Chaddy2222 Guest

    wrote:
    > 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.
    --
    Regards Chad. http://freewebdesign.cjb.cc/
    Chaddy2222, May 23, 2006
    #2
    1. Advertising

  3. Chaddy2222 <> scripsit:

    > 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.
    Jukka K. Korpela, May 23, 2006
    #3
  4. Chaddy2222 Guest

    Jukka K. Korpela wrote:
    > Chaddy2222 <> scripsit:
    >
    > > 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.


    <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.
    --
    Regards Chad. http://freewebdesign.cjb.cc
    Chaddy2222, May 23, 2006
    #4
  5. wrote:
    > 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
    Travis Newbury, May 23, 2006
    #5
  6. Steve Pugh Guest

    Chaddy2222 wrote:

    > 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
    Steve Pugh, May 23, 2006
    #6
  7. Andy Dingley Guest

    Jukka K. Korpela wrote:
    > Chaddy2222 <> scripsit:
    >
    > > 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.


    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" ?

    > > The document type decleration (DTD) tells the web browser what type the document is


    > > what set of rules to use when displaying the website.


    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)
    Andy Dingley, May 23, 2006
    #7
  8. <> scripsit:

    > Jukka K. Korpela wrote:
    >> Chaddy2222 <> scripsit:
    >>
    >>> 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.

    >
    > 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.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, May 23, 2006
    #8
  9. Andy Dingley Guest

    On 23 May 2006 06:28:06 -0700, "Travis Newbury"
    <> wrote:

    >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...
    Andy Dingley, May 23, 2006
    #9
  10. Andy Dingley Guest

    On Tue, 23 May 2006 23:37:39 +0300, "Jukka K. Korpela"
    <> wrote:

    > <> scripsit:
    >
    >> Jukka K. Korpela wrote:
    >>> Chaddy2222 <> scripsit:
    >>>
    >>>> 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.

    >>
    >> 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.


    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?
    Andy Dingley, May 23, 2006
    #10
  11. cwdjrxyz Guest

    wrote:
    > 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.
    cwdjrxyz, May 23, 2006
    #11
  12. Andy Dingley wrote:
    > >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.


    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.
    Travis Newbury, May 23, 2006
    #12
  13. Andy Dingley <> scripsit:

    >> 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).


    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
    (<!DOCTYPE ...>), _not_ a DTD.

    > 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?

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, May 24, 2006
    #13
  14. Toby Inkster Guest

    Travis Newbury wrote:

    > 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.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, May 24, 2006
    #14
  15. Andy Dingley Guest

    Jukka K. Korpela wrote:

    > 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.
    Andy Dingley, May 24, 2006
    #15
  16. <> scripsit:

    > Jukka K. Korpela wrote:
    >
    >> That does not make a document type declaration tell them anything.

    >
    > 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.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, May 24, 2006
    #16
  17. dorayme Guest

    In article <zl2dg.523$>,
    "Jukka K. Korpela" <> wrote:

    > <> scripsit:
    >
    > > Jukka K. Korpela wrote:
    > >
    > >> That does not make a document type declaration tell them anything.

    > >
    > > 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.


    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?

    --
    dorayme
    dorayme, May 24, 2006
    #17
  18. Toby Inkster wrote:
    > Travis Newbury wrote:
    > > 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.


    Speaking from experience I can attest that you can live with one kidney
    Travis Newbury, May 25, 2006
    #18
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PapaRandy
    Replies:
    2
    Views:
    345
    Circa
    Jul 11, 2006
  2. Rolf Welskes
    Replies:
    6
    Views:
    1,443
    Steven Cheng[MSFT]
    Aug 24, 2006
  3. mnshtiwari
    Replies:
    0
    Views:
    752
    mnshtiwari
    Apr 16, 2009
  4. bbxrider

    which doctype to use?? and one other

    bbxrider, Aug 9, 2003, in forum: Javascript
    Replies:
    1
    Views:
    110
    bbxrider
    Aug 9, 2003
  5. Larry Lindstrom
    Replies:
    19
    Views:
    1,271
    Jonathan N. Little
    Jun 12, 2012
Loading...

Share This Page