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

前端之家收集整理的这篇文章主要介绍了将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.f2er.com/html/223974.html

猜你在找的HTML相关文章