Characters in the style sheets must be properly encoded in order to be transmitted and stored. The encoding generally follows the rules set up within the ASCII group character sets (UTF-8, ISO-8859-x...).

When a style sheet is set by another document, such as a style element or a style attribute, the style sheet will accept that character encoding for the entire document. On the other hand, when a style sheet is being imported by a separate file, different priorities take place. These priorities are sorted as follows:

  1. An HTTP "charset" parameter in a "Content-Type" field (or similar parameters in other protocols);
  2. BOM (byte order mark) and/or @charset rule (see below);
  3. or other metadata from the linking mechanism (if any);
  4. charset of referring style sheet or document (if any);
  5. Assume UTF-8.

If the @charset rule is being used, it must be placed at the very beginning of the style sheet document. If there is an appropriate byte order mark used for encoding, it might precede the @charset rule.

The @charset identifier must be followed by the charset name, i.e. @charset "ISO-8859-2".

To see the list of more common IANA approved character sets, go the "HTML 4 Character Encodings" chapter.


›› go to examples ››