添加charset =“utf-8”到一个HTML链接元素有什么影响? [英] Does adding charset="utf-8" to an HTML link element have any effect?

查看:358
本文介绍了添加charset =“utf-8”到一个HTML链接元素有什么影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的HTML文档我没有作者。它包含以下内容:

I'm working with an HTML document I did not author. It contains the following:

<link rel="stylesheet" href="/static/oxygen-fontfacekit/stylesheet.css" charset="utf-8" />

以这种方式指定字符集有任何效果,或者是由Content-类型响应头?

Does specifying the charset in this way have any effect, or is the character set determined by the Content-Type response header?

推荐答案

W3C说


这个想法是浏览器能够应用如果未以任何其他方式为文档指定编码,则对其检索的文档进行正确编码。在 a 链接元素上使用此属性目前已被HTML5规范弃用,因此您应避免使用它在那些元素上。此外,在使用此属性之前还需要考虑一些事情。首先,它没有得到主要浏览器的支持。其次,很难确保信息在任何给定的时间是正确的。文档的作者指出可能会改变文档的编码,而你不知道。如果作者仍未指定其文档的编码,则现在将要求浏览器应用不正确的编码。第三,如果人们遵守指南,并且正确地标记他们的文件,那也不是必要的。

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 a or link element 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.

这篇关于添加charset =“utf-8”到一个HTML链接元素有什么影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆