The CSS solution cannot be correctly parsed due to IE6 Encoding Problems

Source: Internet
Author: User

  Fire Station building school (bkjia.com) NewsWhen I was designing a div + css webpage, IE6 suddenly failed to parse the CSS file normally, so I couldn't solve it for a long time. So I went online to the teacher and finally found a good article on the Internet, I have solved the problem. I would like to thank you for your appreciation.

The web page uses the UTF-8 encoding format, which is no problem, the problem is that the external CSS file defaults to ANSI encoding and is not saved as the UTF-8 format. You may find that this is not a problem in general. However, when a CSS file contains Chinese comments, it may be unsatisfactory! It is estimated that browsers earlier than IE6 cannot correctly parse the CSS file because of the encoding problem, so CSS does not work in IE6. It seems that Microsoft has noticed this problem and fixed it in IE7.



However, there are still many Internet Explorer 6 users. Therefore, this problem must be solved:
Method 1: the CSS, JS and web files are stored in a unified UTF-8 format.
Method 2: Remove Chinese comments in CSS and JS, or change them to English.

The preceding section shows that the CSS file cannot be correctly parsed due to encoding issues in IE6.

Sometimes we find that when the html page we write references an external css file, it can be parsed in IE7 and FF, that is, it can be displayed normally, but it is not parsed in IE6, that is to say, the style in the css file is not applied to our html page at all. Why? At first, I copied and pasted all the styles in the css file to <style> </style> On the html page. After this operation, IE6, IE7, and FF will be displayed normally, this shows what problems should exist in external css files. Why does this problem occur in IE6, but not in IE7 and FF? I googled the website and found that IE6 had strict page encoding requirements. I checked that the css file sent by a friend was encoded in GB2312, while the html file uses UTF-8, the original problem is here. I changed the encoding of the css file content to ed to UTF-8. When I tested it again, everything went back to normal, in addition, I found that my friend's css file was annotated with Chinese characters. It is strongly recommended that my friends do not comment with Chinese characters in the css file. This will also cause Encoding Problems.

Related Article

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.