CSS non-ASCII character best practices, cssascii Best Practices
Problem scenarios
Attribute values of non-ASCII characters are often used when writing styles, as follows:
?
1234567891011 |
.hot_list .sign_discount:before { content: "Full reduction" ; padding: 0 8px; margin-right: 7px; font-size: 12px; line-height: 14px; color: #fff; text-align: center; border-radius: 11px; } |
However, garbled characters may sometimes appear in Chrome:
In addition to content, font fonts are also frequently used for non-ASCII characters, such as font-family: ""
Best practices
To avoid the above Encoding Problems, we recommend that you use backslash escape when non-ASCII characters are involved in CSS to avoid Encoding Problems:
backslash escapes allow authors to refer to characters they cannot easily put in a document. In this case, the backslash is followed by at most six hexadecimal digits (0..9A..F), which stand for the ISO 10646 ([ISO10646]) character with that number, which must not be zero. (It is undefined in CSS 2.1 what happens if a style sheet does contain a character with Unicode codepoint zero.) If a character in the range [0-9a-fA-F] follows the hexadecimal number, the end of the number needs to be made clear.
See http://www.w3.org/TR/CSS2/syndata.html#escaped-characters for details
Therefore, the preceding example can be changed:
?
1234567891011 |
.hot_list .sign_discount:before { content: "\6ee1\51cf" ; padding: 0 8px; margin-right: 7px; font-size: 12px; line-height: 14px; color: #fff; text-align: center; border-radius: 11px; } |