SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru bronze trophy AndrewCooper's Avatar
    Join Date
    Sep 2008
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)

    HTML 4.01 Doctypes

    Hey everyone, just want a confirmation more than anything or should I say, the professionals view / opinion on this matter.

    I know / understand that whitespace that you create within your HTML document doesn't affect anything related to the results on the Web browser application or anything else, tabs, line breaks and so on -- all mainly for readability of the source.

    However, one thing that I'm troubled with is the inconsistency among Websites using the HTML 4.01 DOCTYPES.

    According to the following Websites:


    And I assume many more, but I can't be bothered searching. That's enough proof. Anyway, according to them Websites the HTML 4.01 DOCTYPES should be served like so:

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

    Or something along those lines.

    Yet, since I have been creating Web pages I have always used the following format:

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

    And here's a small list of Websites that use this format for serving their DOCTYPES too:



    Yes..Including W3.org. I've provided six trustworthy sources that say one thing but six other Websites that do one straight line, bear in mind these aren't Websites created by silly-billies.

    Who's in the wrong? Is the actual Web standard to go off what the W3C Technical Recommendations say word by word, line by line? Or should we have the DOCTYPE on one straight line?

    I'm not on any side here. I'm simply asking for clarification on what -the- Web standard is for serving the HTML 4.01 DOCTYPE. I'm more than happy to change the the two line method or stick with the one line method. I've only been serving it as one line because thats what I've seen many other Websites do and its how Adobe Dreamweaver CS3 implements it.

    So, two-line method or one-line method?

    Thanks,

    Andrew Cooper
    Last edited by AndrewCooper; Jul 22, 2009 at 07:01.

  2. #2
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    It makes no difference, I personally prefer to keep it on one line as that is the natural method of marking up elements in HTML however you are perfectly entitled to split it over multiple lines. Web browsers only check for a doctype to see if you are running standards or quirks mode anyway so it won't affect your website or validation in the slightest.

    Interestingly while the W3C website uses a multiline example, if you fail to include a doctype and get the validator to add one in (if submitting code) it will do it on a single line as per your alternative example. Semantically speaking it really makes no difference because the new line does not signify the tag has closed, but for the purpose of conserving any unrequired whitespace I just use a single line as it appears "neater".

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The line feed is entirely up to you, as long as there is some white-space character between the public identifier and the system identifier. It can be one or more spaces, tabs or line feeds.

    The sources you quoted don't say you should include a line feed. They usually present it that way because the line gets so long otherwise, and people might have to scroll horizontally to see the whole thing.

    I write it on one line myself. (But in my book I used the two-line approach since the whole declaration wouldn't fit on the page at a comfortable font size.)
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Guru bronze trophy AndrewCooper's Avatar
    Join Date
    Sep 2008
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    The sources you quoted don't say you should include a line feed. They usually present it that way because the line gets so long otherwise, and people might have to scroll horizontally to see the whole thing.

    I write it on one line myself. (But in my book I used the two-line approach since the whole declaration wouldn't fit on the page at a comfortable font size.)
    Ah yea, I didn't to say that they were saying you should, I meant they implied it more than anything. They were implying that you should use that method because it provides it in that format to you.

    So it's just an issue with having the space on the screen or on paper to present it to the audience? That, or a personal preference?

    So, although the W3C's HTML 4.01 Technical Recommendation section on DTD's provides the DTD to you in a multiline format as does the QA Web page, that doesn't mean it is automatically a Web standard for writing the DOCTYPE in your own documents?

    I understand that it doesn't make any difference in the results it gives or anything. I'm just coming from a standards point of view on how to write the DOCTYPE. I think I'll stick with the one line format as I've always done. I just kind of feel like I'm -betraying- the TR and standards by not writing it in the format the W3C provide it in the TR. Should I feel this way or am I just becoming too much of a W3C rule-abiding developer?

    And thanks for the replies AlexDawson and AutisticCuckoo, I'm happy just you two replying so far [Values your views and opinions highly. And I'm not being a creep -- Honest!].

    Andrew Cooper

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AndrewCooper View Post
    So it's just an issue with having the space on the screen or on paper to present it to the audience? That, or a personal preference?
    Yes.

    Quote Originally Posted by AndrewCooper View Post
    So, although the W3C's HTML 4.01 Technical Recommendation section on DTD's provides the DTD to you in a multiline format as does the QA Web page, that doesn't mean it is automatically a Web standard for writing the DOCTYPE in your own documents?
    No. The doctype declaration (it's not a DTD [document type definition]; that's what it's pointing to) consists of a number of parts:
    1. The Markup Declaration Open delimiter (MDO): '<!'
    2. The word 'DOCTYPE'
    3. The root element name ('html')
    4. Optionally a Formal Public Identifier (FPI)
    5. Optionally a Formal System Identifier (FSI)
    6. Optionally a Declaration Subset Open delimiter (DSO, '['), an internal subset and a Declaration Subset Close delimiter (DSC, '])
    7. The Markup Declaration Close delimiter (MDC): '>'

    There must be one or more white-space characters (space, tab, carriage return, line feed) before the root element name, an FPI, an FSI and an internal subset. Whether you use spaces, tabs or line feeds is entirely up to you. The SGML standard only says there needs to be some white-space.

    Quote Originally Posted by AndrewCooper View Post
    I just kind of feel like I'm -betraying- the TR and standards by not writing it in the format the W3C provide it in the TR. Should I feel this way or am I just becoming too much of a W3C rule-abiding developer?
    That's like feeling guilty about quoting a short text from a book or a newspaper and not putting the line breaks exactly where they were in the original. Unless it's poetry or song lyrics, the line breaks don't have any meaning; they only exist where needed to fit the measure of the page or column.
    Birnam wood is come to Dunsinane


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
  •