CSS @charset Rule

The @charset rule defines the character encoding in a stylesheet.

If used, it must be the first line in the stylesheet.

Example

#

This rule specifies a UTF-8 character encoding.

@charset "UTF-8";

Using @charset

This rule must be the first line in the stylesheet.

@charset cannot be used inside a style attribute.

It also cannot be used inside a <style> element.

This rule is helpful when non-ASCII characters are used in certain CSS properties, such as content.

Syntax

@charset "charset";

Values

#

Value Description
charset The character encoding, such as UTF-8 and iso-8859-15.

Browser support

This table shows when @charset support started for each browser.

Chrome
2.0 May 2009
Firefox
1.5 Nov 2005
IE/Edge
Not Supported
Opera
9.0 Jun 2006
Safari
4.0 Jun 2009

You may also like

Guides