Recently, as a result of the need, I am working on a blog management system. When it is about to be completed, I have never encountered any problems. The page shows normal in IE7 and FF, while in IE6, some CSS codes are invalid. The problem is caused by CSS encoding:
The webpage uses UTF-8 encoding, while CSS uses ANSI encoding. In this case, the CSS style can be recognized by IE8, IE7, and Firefox and will be displayed normally, however, IE6 and earlier versions do not know each other, which leads to the problem described above.
Solution:Use the same encoding for the webpage and CSS file. We recommend that you modify the style of the CSS file to make it consistent with that of the webpage. To modify the CSS file encoding method, you can use editplus to open the CSS file and "Save as". In "encoding", select the same encoding method as the webpage, and then confirm to overwrite the original file.
This is not the caseArticleWhat I want to say is as follows: shortly after the above problems are solved, another encoding problem occurs, that is, all CSS becomes invalid in any browser, dizzy, and finally found, the reason is that in the external CSS file, the first comment statement is garbled due to encoding problems. In fact, the Garbled text of the comment does not affect the output of the aspx file, the key is that the comment end mark * and the comment content are recognized as a character by the browser during encoding, so that the comment statement does not end the mark, and all CSS is commented out, eg:/* place on timeDan */
This is the example"Dan *Because the encoding problem is treated as a character by the browser, the Comment statement will not end, so the following content will be commented out. I have summarized several solutions as follows:
1. Delete all comments to avoid problems (not recommended)
2. Comment in English.
3. The comment mark is separated by a space. For example:/* Comment part */(I think it is the most effective)