Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between HTML Document Type and Content type?

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?

  1. Then what is the content type we specify in meta tags?
  2. Does it have any relation/difference to document type?
  3. How is this content type significant when comes to page rendering?
  4. Does specifying content type help the browser in terms of performance?
  5. Also, what all content types are there?
like image 596
Ivin Avatar asked Oct 11 '25 21:10

Ivin


1 Answers

The HTTP Content-Type header, for which the http-equiv="Content-Type" HTML meta tag is a fallback only, signifies what general type of document the document is. Is it a text/html document and should the browser fire up its HTML parser? Or is it an application/pdf document and the browser needs to load its PDF plugin? Or is it something completely different? This header/tag should also specify the encoding the document is in, if applicable.

The HTML Document Type specifies the exact type and version of the HTML document. Is it an HTML 5 document? HTML 4 Strict? Transitional? Or just legacy tag soup?

like image 175
deceze Avatar answered Oct 14 '25 12:10

deceze