Could someone help me understand the difference between document type and content type of an html/xhtml page?
I know that document type is used by the browsers to determine which mode(standards/quirks) to choose and also to follow which document type schema to be used?
- Then what is the content type we specify in meta tags?
- Does it have any relation/difference to document type?
- How is this content type significant when comes to page rendering?
- Does specifying content type help the browser in terms of performance?
- Also, what all content types are there?
The document type declaration is there mainly for
The HTML5 doctype declaration is solely there for triggering standards mode in browsers, since HTML5 has no document type definition.
The content type is what determines whether a page is served as HTML markup or XML-serialized (XHTML) markup.
For HTML, it is
text/html. This is the default for most Web pages.For XHTML, it is (usually)
application/xhtml+xml.There’s also a character encoding, typically
charset=utf-8.This usually doesn’t matter, though; in most cases the content type will be sent in the Content-Type HTTP header by the server. When a browser picks up the header it will ignore the meta tag.
In HTML5 only the charset is specified:
No.
The same markup, assuming it is well-formed XML, can produce different DOMs in certain cases when it is served as
application/xhtml+xmlas opposed totext/html. These differences are minor, but may have different effects on page rendering.You can write markup that will produce identical DOMs whether served as HTML or XHTML. This is known as polyglot markup.
No.
Concerning HTML/XHTML there are only the two I’ve mentioned. All the other content types (or MIME types) are irrelevant here.