微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将charset =“utf-8”添加到HTML链接元素是否有效?

我正在使用我没有创作的 HTML文档.它包含以下内容
<link rel="stylesheet" href="/static/oxygen-fontfacekit/stylesheet.css" charset="utf-8" />

以这种方式指定字符集是否有效,或者是由Content-Type响应头确定的字符集?

解决方法

W3C says

The idea is that the browser would be able to apply the right encoding to the document it retrieves if no encoding is specified for the document in any other way. The use of this attribute on an aorlinkelement is currently deprecated by the HTML5 specification,so you should avoid using it on those elements.In addition,there are some things to consider before using this attribute. Firstly,it is not well supported by major browsers.Secondly,it is hard to ensure that the information is correct at any given time. The author of the document pointed to may well change the encoding of the document without you kNowing. If the author still hasn’t specified the encoding of their document,you will Now be asking the browser to apply an incorrect encoding. And thirdly,it shouldn’t be necessary anyway if people follow the guidelines… and mark up their documents properly.

原文地址:https://www.jb51.cc/html/223974.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐