@charset CSS At-Rule
@charset CSS at-rule is used to define the character encoding of an external CSS file. It must appear at the very beginning of the CSS file, before any other rules or declarations. Its primary purpose is to ensure that the browser correctly interprets and renders the CSS file with the specified character encoding.
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.
- 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.
The following table will show you the current browser support for the at-rule
|Tablets / Mobile|
Last updated by CSSPortal on: 30th September 2023