Search code examples
htmlcharacter-encodingmeta

Which meta tags before title tag in html with doctype 4.01 Transitional?


So my question is about which meta tags are placed before the title tag when set in the head tag in html with doctype 4.01 Transitional.

Here I give an example:

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

<html>
<head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <title>Index</title>
   <meta name="keywords" content="whatsoever">
   <meta name="description" content="ask stackoverflow">
   <meta name="author" content="gugol">

    <link rel="stylesheet" type="text/css" href="../css/nicestyles.css">
</head>
<body></body>
</html>

I think I should have the charset attribute first so that everything in the html document is read under the character encoding for the HTML document. But have some doubts about the others.

What would be just the right order??


Solution

  • Modern browsers let you specify the character encoding in a meta tag so that it is applied even to elements preceding it. However, such a tag should appear as early as possible according to HTML 4.01, clause 5.2.2 Specifying the character encoding. HTML5 CR clarifies further, in clause 4.2.5.5 Specifying the document's character encoding, that “the element containing the character encoding declaration must be serialized completely within the first 1024 bytes of the document”.

    The point here is that unless the encoding has been specified in HTTP headers or by data interpretable as Byte Order Mark at the start of a document, the browser will scan some initial part, such as one kilobyte, of the document, then infer or guess the encoding from it, tentatively parsing it as Ascii data and recognizing a meta tag if there is one.

    Other than this, no order restrictions are placed on the content of a head element, and there is no reason to expect that the order of meta elements would matter.