@charset CSS At-Rule


The @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.


@charset "charset";


  • 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.


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

Browser Support

The following table will show you the current browser support for the at-rule @charset.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 30th September 2023