at-rule

@charset — CSS reference

A legacy encoding declaration recognized as a special byte sequence at the beginning of external CSS, not an ordinary CSSOM rule. Serve CSS with correct encoding metadata and UTF-8 bytes. Inline style elements are already decoded by the document.

Formal Syntax & Structure

css syntaxcss
@charset "UTF-8";

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>@charset</title><style>body{margin:8px;font:16px/20px sans-serif;color:black;background:white}@charset "UTF-8"; #a{color:green}</style><body><p id="a">Example text</p></body></html>
CSS Reference