concept
Charset encoding declaration — CSS reference
The special byte sequence at the beginning of an external stylesheet can declare its encoding under the CSS Syntax decoding rules. It is not an ordinary at-rule in the parsed rule list. Use UTF-8 and accurate transport metadata; a DOM-injected style block is already Unicode and cannot test byte decoding. Here Unicode text is displayed directly as a control.
Formal Syntax & Structure
css syntaxcss
@charset "UTF-8";Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>charset-encoding-declaration</title><style>body{margin:8px;font:16px/1.5 sans-serif;color:black;background:white}#a{box-sizing:border-box}
</style><body><p id="a" lang="fa" dir="rtl">متن فارسی</p></body></html>