@charset CSS At-Rule

Description

The @charset CSS at-rule is used to set the encoding of an external CSS stylesheet. This at-rule is useful when using non-ASCII characters in some CSS properties, like content.
For an external style sheet, the browser sequentially looks at the following items to determine the encoding of the style sheet:

1. The encoding that the server gives;
2. @charset rule;
3. the charset attribute of the element (this attribute is deprecated, do not use it).

The above list has a clearly defined hierarchy - the higher the item is, the higher its priority. If none of the items are found, the UTF-8 encoding will be assumed.

Syntax

@charset "charset";

Values

  • charsetIs a <string> denoting the character encoding to be used. It must be the name of a web-safe character encoding defined in the IANA-registry, and must be double-quoted, following exactly one space character, and immediately terminated with a semicolon.

Example

@charset "UTF-8";
@charset "iso-8859-1";

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
5.51221.594
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
218410.14X