DOCTYPE Declaration :confused:

Discussion in 'HTML & Website Design' started by punediary, Oct 10, 2011.

  1. #1
    What is doctype declaration? And how it is important for sites???
     
    punediary, Oct 10, 2011 IP
  2. webdeveloperindia

    webdeveloperindia Active Member

    Messages:
    90
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    73
    #2
    The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
     
    webdeveloperindia, Oct 11, 2011 IP
  3. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #3
    Because Microsoft and Internet Explorer are inept, incompetent and stupid, we are forever cursed with the need for the doctype. Microsoft, in all their ineptitude, incorrectly read the W3C specifications and computes the width of elements to include padding, the border and margin. NO other browser did that! So thanks to them, in order to tell browsers which spec you are following, the W3C spec or Microsoft's screwup, you must include the doctype.

    As further evidence of this, those of you who serve XHTML as 'application/xhtml+xml' or use XML will notice no doctype is required! That's because IE is so ancient and backwards that it never started supporting XHTML served as true XHTML until IE9! And that's while every other browser had supported XHTML since the 90s!

    And people wonder why I constantly say, "No one should *ever* use IE!"
     
    drhowarddrfine, Oct 11, 2011 IP
  4. punediary

    punediary Peon

    Messages:
    150
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ok....thanks for giving me a very useful information...can you explain me what is XHTML & text/html ratio?
     
    punediary, Oct 12, 2011 IP
  5. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #5
    There's a new thing out callled Google. You should learn how to use it.
     
    drhowarddrfine, Oct 12, 2011 IP
  6. AliceWonder

    AliceWonder Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    A doctype is required for XHTML sent with correct mime type. Without it, the XML parser does not know what HTML entities are defines.

    And for the record, Mozilla will render pages differently based upon the doctype as well.

    HTML5 is lazy in that neither sent as html or xml is the full path to the doctype required, but that's also why you can only use a few named entities in HTML5 sent as XML (parser dies if you try, say, " because it is not defined)
     
    Last edited: Oct 12, 2011
    AliceWonder, Oct 12, 2011 IP
  7. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #7
    Of course! Microsoft so screwed up the web that all browsers have to follow quirks mode now.
    Run that through your translator again cause it makes no sense.
     
    drhowarddrfine, Oct 12, 2011 IP
  8. AliceWonder

    AliceWonder Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You are ignorant.

    I hate MS more than anyone, but the doctype has absolutely nothing to do with them.
    The doctype is straight from SGML, which HTML and XML are both subsets of.

    It is an SGML declaration. It always has been.
     
    AliceWonder, Oct 12, 2011 IP
  9. AliceWonder

    AliceWonder Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
  10. ademmeda

    ademmeda Active Member

    Messages:
    354
    Likes Received:
    3
    Best Answers:
    3
    Trophy Points:
    70
    #10
    I use

    <!doctype html>
    Code (markup):
    It is the document type declaration for HTML 5.
     
    ademmeda, Oct 12, 2011 IP
  11. AliceWonder

    AliceWonder Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    But it does not define the location of the doc type, which is why named entities do not work with html5 sent as xml. The xml parser does not know what to do with them because the location of the doctype is not defined.

    It's a pain in the ass for including MathML inside html5 because MathML uses a lot of named entities, so you have to convert them all to numbered entities or UTF-8 equivalents before sending it to a parser for rendering. A real PITA.
     
    Last edited: Oct 12, 2011
    AliceWonder, Oct 12, 2011 IP
  12. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #12
    @AliceWonder - Your first posts are not proper English and I don't understand what you are saying. Your last two posts are way off topic and way over the head of anyone here on DP.

    Named entities in html5 don't work when sent as XML because they're XML! Or do you mean XHTML? In any case, you are off topic.

    EDIT: Ah! I see. I looked at your home page and see you serve XHTML. Most excellent! Long live XML/XHTML! But this won't go anywhere on this board.
    Side note: I have an ecommerce restaurant ordering system which is all XML/XHTML/XSLT. I don't need schooling on that.
     
    drhowarddrfine, Oct 12, 2011 IP
  13. AliceWonder

    AliceWonder Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Nameed entities do work in XML when they are defined in the doc type.

    Do you not comprehend?

    Here's the MathML doctype (MathML is XML - just in case you were not aware) :

    http://www.w3.org/Math/DTD/mathml2/mathml2.dtd

    You will find the named entities defined there, named entities that have been used by LaTeX to MathML exporters for eons and now don't work in html5 without passing them through a regex because w3c decided a doctype was not necessary.

    Here's the XHTML 1.0 doctype -

    http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd

    With that declared in the doctype, you can use all kinds of cool named entities because they are defined in the doctype -

    This silly claim of yours that the doctype is a result of MS is patently false. They have been used in both HTML and XML for reasons that have absolutely nothing to do with MS. Most notably, to define what tags are legal in what context and and what attributes are legal in what context.

    XML is now moving to namespaces for that - and if you want to bitch at MS, that's where you bitch, because they have been using namespaces in HTML where they were not defined and did not belong.
     
    Last edited: Oct 12, 2011
    AliceWonder, Oct 12, 2011 IP
  14. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #14
    Yes, and I totally agree. But we're not talking about XML here. Do you not comprehend?
    Then you don't know your internet history.
    Now?! Where have you been? It's in the original spec!

    The rest of your drivel makes no sense in this context because you are waaayyyy off topic, little girl. I don't think I've ever seen you on the W3C irc channel, mail or the XML/XSL message boards so you have no place to lecture me. I've been doing this longer than you.
     
    drhowarddrfine, Oct 12, 2011 IP
  15. AliceWonder

    AliceWonder Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #15
    I do not think you work with XML utilities very often.

    By "now moving to namespaces" I was not indicating they were something new to XML but rather how utilities that use XML work with it.

    For example, with the php libxml wrapper DOMDocument.

    You can use it in a strict mode (set $dom->validateOnParse) where you can not add elements to the node that violate the document type, but you can not use that strict mode with (x)html 5 because it does not know where to get the DOCType to identify what nodes and attributes are actually legal.

    It's a royal pain because unless you have that set, it will allow you to specify the same id twice and thus getElementById can't be used. (x)html5 is thus more difficult to work with because the W3C wrote a lazy spec that does not tell parsers where they can grab the actual DDT from.

    And if you want to talk about what is in the original spec, doctype was in SGML before HTML existed, thus MS rendering of HTML has nothing to do with it.
     
    Last edited: Oct 12, 2011
    AliceWonder, Oct 12, 2011 IP
  16. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #16
    Not anymore, no. I hire a freelancer now.

    You *are* aware browsers do not fetch a DTD from the 'net, right? I don't do PHP so can't comment about your other stuff.
    Did you not read PPK's explanation? Or do you not understand? Don't make me rake you over the coals for that statement. I was there. Don't pretend you need to teach me anything.
     
    Last edited: Oct 13, 2011
    drhowarddrfine, Oct 13, 2011 IP
  17. punediary

    punediary Peon

    Messages:
    150
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    All posts are read by me....bit i think no one give me the answer about text/html ratio?
     
    punediary, Oct 21, 2011 IP
  18. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #18
    That is not a ratio. It's part of the mime type to tell the browser the text represents html. I also told you to Google for that.
     
    drhowarddrfine, Oct 21, 2011 IP