Accesskey n skips to in-page navigation. Skip to the content start.
These tests check whether a user agent follows the CSS 2.1 specification when dealing with character encodings for CSS style sheets.
See the results below for user agents tested. This section summarizes the results of those tests. In what follows, 'HTML' means HTML4.01, HTML5 or XHTML 1.0 served as text/html. XML means XHTML 1.0 or XHTML 1.1 served as application/xhtml+xml.
All user agents but IE7 supported encoding declarations using HTTP and all supported @charset. Only IE8, Firefox, Opera support encoding declarations using the charset attribute.
Only IE and Firefox appear to respect the rule that a CSS file with no encoding declaration assumes the encoding of the HTML file that called it. In this situation Opera seems to default to UTF-8, while Safari and Chrome default to ISO Latin 1.
Other conclusions are TBD for now.
These are results for the latest versions of each user agent tested. A green background (yes) means that the assertion associated with the test held true; red (no) means that it did not; orange (partially) means that it was only partially true. To view the assertion, mouse over the text in the left column.
Results are given for five types of document format: H4 (HTML 4.01), H5 (HTML5), XH (XHTML 1.0 served as text/html), X (XHTML 1.0 served as XML), X11 (XHTML 1.1, served as XML). Results across all formats were the same for all tests, so only one cell per test per browser is included in the table.
The basic declarations tests come in sets of three; a feature is only supported if the result is positive for all three tests in a group (this is to account for different default encodings).
| UA | IE | IE | Firefox | Opera | Safari | Chrome | |
|---|---|---|---|---|---|---|---|
| version | 8 | 7 | 3.6.3 | 10.51 | 4.05 | 4.1.249.1045 | |
| OS | XP | XP | XP | XP | XP | XP | |
| date | 20100412 | 20100412 | 20100412 | 20100412 | 20100412 | 20100412 | |
| HTTP declarations | html utf8, css http iso1 The user agent respects the encoding of a css stylesheet declared in HTTP. | yes | no | yes | yes | yes | yes |
| html utf8, css http iso15 The user agent respects the encoding of a css stylesheet declared in HTTP. | yes | no | yes | yes | yes | yes | |
| html iso1, css http utf8 The user agent respects the encoding of a css stylesheet declared in HTTP. | yes | no | yes | yes | yes | yes | |
| @charset declarations | html utf8, css @charset iso1 The user agent respects the encoding of a css stylesheet declared in an @charset rule. | yes | yes | yes | yes | yes | yes |
| html utf8, css @charset iso15 The user agent respects the encoding of a css stylesheet declared in an @charset rule. | yes | yes | yes | yes | yes | yes | |
| html iso1, css @charset utf8 The user agent respects the encoding of a css stylesheet declared in an @charset rule. | yes | yes | yes | yes | yes | yes | |
| link charset | html utf8, link charset iso1 The user agent respects the encoding of a css stylesheet declared in a charset attribute on the HTML link. | yes | no | yes | yes | yes | yes |
| html utf8, link charset iso15 The user agent respects the encoding of a css stylesheet declared in a charset attribute on the HTML link. | yes | no | yes | yes | no | no | |
| html iso-8859-1, link charset utf8 The user agent respects the encoding of a css stylesheet declared in a charset attribute on the HTML link. | yes | no | yes | yes | no | no | |
| Inheritance from HTML encoding | html iso1 The user agent applies the encoding of the HTML file to a css stylesheet whose encoding is not otherwise declared. | yes | yes | yes | no | yes | yes |
| html iso15 The user agent applies the encoding of the HTML file to a css stylesheet whose encoding is not otherwise declared. | yes | yes | yes | no | no | no | |
| html utf8 The user agent applies the encoding of the HTML file to a css stylesheet whose encoding is not otherwise declared. | yes | yes | yes | yes | no | no |
Assertion:
Link to tests: HTTP declarations - @charset declarations - link charset - Inheritance from HTML encoding
| UA | IE | IE | Firefox | Opera | Safari | Chrome | |
|---|---|---|---|---|---|---|---|
| version | 8 | 7 | 3.5.1 | 9.64 | 4.0.2 | 2.0.172.37 | |
| OS | XP | XP | XP | XP | XP | XP | |
| date | 20100412 | 20100412 | 20100412 | 20100412 | 20100412 | 20100412 | |
| UTF-8 signature | html iso-8859-1, css bom The user agent uses a UTF-8 signature without an @charset at the beginning of a css stylesheet to indicate that the encoding is UTF-8. | yes | yes | yes | yes | yes | yes |
| html iso-8859-15, css bom The user agent uses a UTF-8 signature without an @charset at the beginning of a css stylesheet to indicate that the encoding is UTF-8. | yes | yes | yes | yes | yes | yes | |
| @charset and BOM | html iso-8859-1, css bom and @charset utf8 (in lowercase) When a stylesheet has a BOM and an @charset declaration that is for the right Unicode encoding, the stylesheet works. | yes | yes | yes | yes | yes | yes |
| html iso-8859-1, css bom and @charset utf8 (in uppercase) When a stylesheet has a BOM and an @charset declaration that is for the right Unicode encoding, the stylesheet works. | yes | yes | yes | yes | yes | yes | |
| html iso-8859-15, css bom and @charset iso15 When a stylesheet has a BOM and a @charset declaration that is not for a Unicode encoding, the stylesheet fails. | no | yes | yes | no | no | no |
Assertion:
Link to tests: UTF-8 signature - @charset and BOM
| UA | IE | IE | Firefox | Opera | Safari | Chrome |
|---|---|---|---|---|---|---|
| version | 8 | 7 | 3.5.1 | 9.64 | 4.0.2 | 2.0.172.37 |
| OS | XP | XP | XP | XP | XP | XP |
| date | 20100412 | 20100412 | 20100412 | 20100412 | 20100412 | 20100412 |
| html utf-8, css @charset unknown When a stylesheet has a @charset declaration with an unknown value, the stylesheet should be ignored. | yes | no | yes | no | no | no |
Assertion:
Link to tests: Unknown encoding
These tests are only valid if the @charset rule is recognized by the user agent. The result of that test is shown on the first data row.
| UA | IE | IE | Firefox | Opera | Safari | Chrome |
|---|---|---|---|---|---|---|
| version | 8 | 7 | 3.5.1 | 9.64 | 4.0.2 | 2.0.172.37 |
| OS | XP | XP | XP | XP | XP | XP |
| date | 20100412 | 20100412 | 20100412 | 20100412 | 20100412 | 20100412 |
| html utf8, css @charset iso15 The user agent respects the encoding of a css stylesheet declared in an @charset rule. | yes | yes | yes | yes | yes | yes |
| no semicolon at end of charset rule If a @charset declaration is missing a final semicolon, the encoding declaration will not be recognised. | yes | no | yes | no | yes | yes |
| extra spaces after @charset If a @charset declaration has more than one space after 'charset', the encoding declaration will not be recognised. | yes | no | yes | no | no | no |
| extra spaces before colon in charset rule If a @charset declaration has spaces just before the colon, the encoding declaration will not be recognised. | yes | no | yes | no | no | no |
| linebreak in middle of charset rule If a @charset declaration has a line break in the middle, the encoding declaration will not be recognised. | yes | no | yes | no | yes | yes |
| single quotes around charset name If a @charset declaration value has single, rather than double, quotes around it, the encoding declaration will not be recognised. | yes | no | yes | no | no | no |
| blank line before @charset If a @charset declaration is not on the first line of the file, the encoding declaration will not be recognised. | yes | yes | yes | yes | 1 | yes |
| spaces before @charset If a @charset declaration does not start at the beginning of the first line of the file (when there is no BOM), the encoding declaration will not be recognised. | yes | yes | yes | yes | 1 | yes |
Assertion:
Link to tests: typos
Notes:
These tests are only valid if the relevant HTTP declarations, @charset rules and charset links have an effect. The results for those tests are shown on the first two data rows.
| UA | IE | IE | Firefox | Opera | Safari | Chrome |
|---|---|---|---|---|---|---|
| version | 8 | 7 | 3.5.1 | 9.64 | 4.0.2 | 2.0.172.37 |
| OS | XP | XP | XP | XP | XP | XP |
| date | 20090417 | 20090417 | 20090417 | 20090417 | 20090417 | 20090417 |
| html utf8, css @charset iso15 The user agent respects the encoding of a css stylesheet declared in an @charset rule. | yes | yes | yes | yes | yes | yes |
| html utf8, link charset iso15 The user agent respects the encoding of a css stylesheet declared in a charset attribute on the HTML link. | yes | no | yes | yes | no | no |
| http vs. @charset An HTTP encoding declaration for a stylesheet takes precedence over an @charset declaration. | yes | no | yes | yes | yes | yes |
| http vs. charset link An HTTP encoding declaration for a stylesheet takes precedence over a charset attribute link declaration. | yes | n/a | yes | yes | n/a | n/a |
| http vs. bom An HTTP encoding declaration for a stylesheet takes precedence over a UTF-8 signature. | yes | no | yes | yes | no | no |
| @charset vs. charset link An HTTP encoding declaration for a stylesheet takes precedence over a UTF-8 signature. | yes | n/a | yes | yes | n/a | n/a |
Assertion:
Link to tests: Precedence
Tell us what you think (English).
Content first published 2009-04-17. Last substantive update 2009-04-17 7:22 GMT. This version 2009-04-17 7:22 GMT
For the history of document changes, search for results-lang-and-cjk-font in the i18n blog.
Copyright © 2007-2009 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply. Your interactions with this site are in accordance with our public and Member privacy statements.