Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does adding charset="utf-8" to an HTML link element have any effect?

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" />

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

like image 370
davidchambers Avatar asked Jun 19 '13 18:06

davidchambers


1 Answers

The 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 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.

like image 189
Raedwald Avatar answered Sep 27 '22 17:09

Raedwald