When a style sheet is embedded in another document, such as in the STYLE element or "style" attribute of HTML, the style sheet shares the character encoding of the whole document.
When a style sheet resides in a separate file, user agents must observe the following priorities when determining a style sheet's character encoding (from highest priority to lowest):
- An HTTP "charset" parameter in a "Content-Type" field (or similar parameters in other protocols)
- BOM and/or @charset (see below)
- <link charset=""> or other metadata from the linking mechanism (if any)
- charset of referring stylesheet or document (if any)
- Assume UTF-8
Example:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet title="1" href="" type="text/css"?>
<a>
<b>Test: À</b>
</a>
s1.css:
@charset "UTF-8";
a:before {
display: block;
content: "À";
}
a {
display: block;
color: #ccc;
}
b {
display: block;
}
Cheers