New tests & results: CSS encoding detection

These tests examine whether user agents follow the rules in CSS 2.1 about detecting the encoding of CSS style sheets. This is particularly important if you style sheet uses non-ASCII characters in such things as class names, content, or font names.

Summary of initial results:

Of the user agents tested, only Firefox and IE8beta pass all tests.

IE7 doesn't recognise character encodings declared in either the HTTP header or the charset attribute of the link element.

Opera does not apply the encoding of the HTML file to the CSS in the absence of other cues to encoding, treating the CSS file as UTF-8. However, it doesn't default to UTF-8 or ISO Latin 1 if the encoding of the HTML is unknown. This means that you need to explicitly declare the encoding for CSS files if they contain characters beyond the Latin 1 range.

Safari appears, unusually, doesn't match any class in the HTML if @charset appears on the second line. It's not clear why.

The indications from the results are that if you have characters above the ASCII range in your CSS style sheet, you should either use the @charset rule, or use a byte-order mark at the beginning of a UTF-8 encoded file. Otherwise your style declarations may fail in one user agent or another.

Richard Ishida
Internationalization Lead
W3C (World Wide Web Consortium)

Received on Friday, 8 August 2008 18:35:22 UTC