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.
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!"
ok....thanks for giving me a very useful information...can you explain me what is XHTML & text/html ratio?
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)
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.
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.
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.
@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.
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.
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.
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.
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.
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.