CSS non-ASCII character best practices, cssascii Best Practices

Source: Internet
Author: User

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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.