Solution and Cause Analysis for failure in parsing CSS files in IE6
Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
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.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.