Syntax
@charset "UTF-8";
Example
@charset "UTF-8";
Common use cases
- Ensuring correct encoding for non-ASCII characters
- Required when using special characters in CSS strings
- Avoiding encoding issues in older browsers
Practical developer insight
@charset must be the very first rule in the file — no spaces or comments before it. In modern projects with UTF-8 everywhere, it's rarely needed.