html - 带有 doctype 4.01 Transitional 的 html 中的标题标签之前有哪些元标签?

标签 html character-encoding meta

所以我的问题是,当使用 doctype 4.01 Transitional 在 html 的 head 标签中设置时,哪些元标签会放置在标题标签之前。

这里我举个例子:

<!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>

我认为我应该首先拥有 charset 属性,以便在 HTML 文档的字符编码下读取 html 文档中的所有内容。但对其他的有一些疑问。

什么才是正确的顺序?

最佳答案

现代浏览器允许您在 meta 标记中指定字符编码,以便它甚至可以应用于其前面的元素。然而,根据 HTML 4.01 条款5.2.2 Specifying the character encoding,这样的标签应该尽早出现。 。 HTML5 CR 在 4.2.5.5 Specifying the document's character encoding 条款中进一步澄清,“包含字符编码声明的元素必须在文档的前 1024 个字节内完全序列化”。

这里的要点是,除非编码已在 HTTP header 中指定或通过可解释为文档开头的字节顺序标记的数据指定,否则浏览器将扫描文档的某些初始部分,例如 1 KB,然后从中推断或猜测编码,尝试将其解析为 Ascii 数据并识别 meta 标记(如果有)。

除此之外,head 元素的内容没有顺序限制,并且没有理由认为 meta 元素的顺序很重要。

关于html - 带有 doctype 4.01 Transitional 的 html 中的标题标签之前有哪些元标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17138634/

相关文章:

html - 背景无法在 Chrome 中正确呈现

Javascript 鼠标悬停在动态数量的元素上

html - DIV 向右浮动 DIV 向左浮动

mysql - MySQL 中的 utf8_general_ci 和 utf8_unicode_ci 有什么区别?

HTML错误: Refused to load the script because it violates the following Content Security Policy directive

html - 在移动设备上从右上到下引导网格

java - é 变成 &195;#169 然后变成 É 我该如何解决这个编码问题?

R 编码 - 保存为 UTF-8,但字符错误(我认为)

javascript - 如果其他域使用 iframe 显示我的网站,如何重定向到错误页面

html - 将 IE9 文档模式更改为 IE9 标准