使用Windows-1252编码的HTML5文档的验证错误
w3.org html验证器 https://validator.w3.org 出乎意料地显示出Html5文档的错误使用编码ISO-8859-1。
消息是:
错误
旧编码Windows-1252所使用的旧版。文档必须使用UTF-8。
我发现许多资源仅表示UTF-8是推荐的编码。 我错过了什么,还是W3验证器错误消息值得怀疑?
例子:
<!DOCTYPE html>
<html lang="fr">
<head>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Untitled document</title>
</head>
<body>
<p>
à la mode
</p>
</body>
</html>
The w3.org HTML validator https://validator.w3.org unexpectedly shows an error for a HTML5 document which uses the encoding iso-8859-1.
The message is:
Error
Legacy encoding windows-1252 used. Documents must use UTF-8.
I found many resources which only indicate UTF-8 being the recommended encoding.
Did I miss something, or is the w3 validator error message questionable?
Example:
<!DOCTYPE html>
<html lang="fr">
<head>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Untitled document</title>
</head>
<body>
<p>
à la mode
</p>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在HTML5中,要指定文档的charset,您应该使用较新的
&lt; meta charset =“ ...”&gt;
,而不是较旧的&lt; meta http-equiv =“ content-键入“ content =” text/html
;
也:
这意味着验证器是正确的。您不允许您在现代HTML中使用
Windows-1252
/ISO-8859-1
(或任何其他CharSet),仅在UTF-8中。这不仅是建议,而且是一项要求。特定的Web浏览器是否选择执行 此要求是另一回事
In HTML5, to specify the document's charset, you should use the newer
<meta charset="...">
instead of the older<meta http-equiv="Content-Type" content="text/html; charset=...">
(which is still supported for legacy reasons), eg:But, that being said, the current HTML5 standard states:
As well as:
Which means, the validator is correct. You are not allowed to use
Windows-1252
/ISO-8859-1
(or any other charset) anymore in modern HTML, only UTF-8. It is not just a recommendation, it is a requirement.Whether or not particular web browsers choose to enforce this requirement is another matter, though...