Easy Tutorial
❮ Css3 Pr Box Lines Sel Target ❯

CSS @charset Rule

Example

Set the character encoding used in the stylesheet to UTF-8:

@charset "UTF-8";

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
@charset 2.0 12.0 1.5 4.0 9.0

Property Definition and Usage

The @charset property specifies the character encoding used in the style sheet (.css suffix) and can only be used in CSS files.

It must be the first element in the style sheet and must not be preceded by any characters.

If multiple @charset rules are declared, only the first one will be used, and it cannot be used in HTML elements or within HTML pages, i.e., it cannot be used inside the <style> element.


Syntax

@charset "charset";
Value Description
charset Specifies the character set to use.

More Examples

Example

@charset "UTF-8";
@charset "utf-8"; /* Case insensitive */
/* Set the CSS encoding format to Unicode UTF-8 */
@charset 'iso-8859-15'; /* Invalid, incorrect quotes used */
@charset 'UTF-8';       /* Invalid, incorrect quotes used */
@charset  "UTF-8";      /* Invalid, more than one space */
@charset "UTF-8";       /* Invalid, extra space before @ */
@charset UTF-8;         /* Invalid, UTF-8 not quoted */
❮ Css3 Pr Box Lines Sel Target ❯