SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Doctype

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Montreal
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Doctype

    Can somebody clarify foe me what exactly is the difference between these 2 Doctypes?

    a)<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

    b) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "hmpro6.dtd">

    What difference will it make if I use one or the other?

    Thanks
    Hrisula

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The second one, I think, uses a locally saved version of the Document Type Definition (DTD).

    It wouldn't have any effect on your pages if you use the second, unless of course, you've been editing the file

    -Sam
    Sam Hastings

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Montreal
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean "unless of course, you've been editing the file"?? I don't get it.

    Well, the problem is that things look differently when I use the same script with one or the other doctype. This does not seem proper to me, it scares me. With all these different platforms, browsers and versions... I just don't know...

    Bottom line is this: I want my coding to be good and the pages to display almost the same way no matter what the platform, browser, version etc.
    So, what is your opinion, which DOCTYPE should I use?
    Thanks
    Hrisula

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hrisulaz
    What do you mean "unless of course, you've been editing the file"?? I don't get it.
    Sorry, what I meant was, if you've been editing the file 'hmpro6.dtd' file, then it may display differently.

    Actually...on second thoughts, was the page with the second DOCTYPE tag in generated by some king of WYSIWYG editor?

    -Sam
    Sam Hastings

  5. #5
    SitePoint Addict
    Join Date
    Sep 2003
    Location
    Europe
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should use this one:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    see W3C valid DTD list

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Montreal
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the responses.

    I have no acces to this 'hmpro6.dtd' file, so I cannot edit it. My web pages are not generated with any editor.

    My main problem is this; when I incorporate the scrollbar-coloring style to the "correct" DOCTYPE, my scrollbars remain grey. I can only achieve colorful scrollbars if I use the second DOCTYPE. Why is that?

    So, The million dollar question is: what do I really gain if I use the "correct" DOCTYPE? If the output is correct, and the web page is validated without any errors, should we really care what kind of DOCTYPE we use?

    Now, don't jump if I ask this question, I checked around forums & tutorials regarding DOCTYPEs and really I do not know what to do. Again, all I want is my pages to show correctly on any platform, with any browser, any version.

  7. #7
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the scrollbar thing has already been answered over here: http://www.sitepointforums.com/showt...hreadid=131491
    So, The million dollar question is: what do I really gain if I use the "correct" DOCTYPE? If the output is correct, and the web page is validated without any errors, should we really care what kind of DOCTYPE we use?
    A doctype is a link to a Document Type Definition, or DTD. The DTD defines the standard that the page att attempting to meet. A page that is perfectly valid HTML4 will not be valid XHTML1 - the DOCTYPE is there to tell a browser/validator/martian *precisely* what markup language the document is written in.

    Without a correct DOCTYPE, your page won't validate, since it's the DTD that defines what "validate" MEANS.

    This bit: "-//W3C//DTD HTML 4.01 Transitional//EN" is an identifier that says "HTML4 Transitional". Some readers will recognise this, and know what to do, so they may ignore the other bit.

    This bit: "http://www.w3.org/TR/html4/loose.dtd" (or "hmpro6.dtd", in one of your examples) is a URL, linking to the actual DTD file itself. Go look at http://www.w3.org/TR/html4/loose.dtd if you don't believe me - there really is a file there.

    If a reader doesn't recognise the first identifier, they may download the DTD an attempt to use the rules in there to figure out what to do with your file. While this is rare in the HTML world, it's much more common over in XML-land.

    In your second example, it's unlikely that any browser is going to be able to find "hmpro6.dtd". In any case, most web browsers look for specific DOCTYPE strings as a whole unit, and may not recognise "near misses".

    In case you've not seen it yet, try this article: http://www.alistapart.com/stories/doctype/
    Last edited by blufive; Oct 3, 2003 at 12:23.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Montreal
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much, you have enlightened me.
    I will follow the rules and use the correct DOCTYPE, because now I understand better its importance.
    I appreciate you taking the time to explain to me (in a manner that I can understand) something that has been asked a million times.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •