charset (HTML attribute)
charset attribute is intended to identify the
character set used in the document that’s referenced within the
This example indicates that the referenced document is written in Japanese:
<link href="okinawa.html" rel="parent" charset="euc-jp"/>
The value taken by
charset is a standard character set encoding name (e.g.
"UTF-8") defined by IANA.
In testing this
attribute, I was unable to see any difference in behaviour/appearance
regardless of whether the attribute was used or not. However, one reader
has stated that in his tests that omitting this attribute would cause
generated content to appear as gibberish if certain conditions were all
true (namely that the encoding of the document and the linked style sheet
differed and the server was not sending the correct encoding information
in the Content-Type header). Adding in a
that used the same encoding value as the linked stylesheet corrected the
problem, he reported.
- Mon, 04 Jan 2010 15:29:50 GMT
@AutisticCuckoo I tried to recreate the example you used, but for whatever reason all the parameters were not lining up and I couldn't get it to break, hence was unable to fix again using charset. However, I will update the reference with your wording, with caveats
- Wed, 12 Mar 2008 09:01:25 GMT
At least Firefox and Opera do honour this attribute, which can be evidenced if you use generated content. If the external style sheet uses a different character encoding than the document that links to it (and the server doesn't send encoding information in the Content-Type header), the generated content will be gibberish if it contains characters outside the US-ASCII repertoire. Adding a CHARSET attribute to the LINK element fixes the problem in FF2.0 and Opera 9.