Although I also want IE6 to die soon, my subjective initiative is too limited after all. The only thing we can do is to use some means to alleviate the pain caused by IE6.
1. Use document types. Try to use the strictest document type to ensure that your page runs in standards mode. Although using them, you may not be able to use many tags, such as b, s, font, etc., but they can all be replaced with CSS.
1.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2." http://www.w3.org/TR/html4/strict.dtd ">
Or the simplest <!doctype html">, which is the only document type recognized by HTML5, and the browser will automatically convert to the above one. Don’t use xhtml document declaration. It originally wanted to make html a transitional product, but as everyone knows I am just a passing visitor, and when using it, the nodeName of the element may be case-sensitive, which is very troublesome.
2. Use position: relative
In layout, always consider positioned layout first and then floating layout. IE's floating model is crazy.
3. Use display:inline
If you must use floats, follow them with display:inline. Because there is a bug that easily occurs in IE6. It will appear as long as a float and a margin value in the same direction as the float are set for the block container element. For example, if we set float:left and margin-left:100px for the div element, it will become margin-left:200px in IE6.
4. Please do not use comment nodes. There are two hateful things involved here. One is a redundant character bug. You can refer to this article "Phantom of the Opera Bug" by Yang Zhengyi (Ah Yi) of this blog. The second is a bug in IE's full range of search APIs. document.all, document.getElementsByTagName and document.querySelectorAll may all return comment nodes.
5. For the hover effect, remember to use the a element with the href attribute to nest it in IE: hover is only effective for the a tag, and the tag must have the href attribute explicitly set.
6. Do not use percentages in style settings
IE has a problem calculating percentages.
7. Let the element get hasLayout
For details, please google Baidu for this great academic study "On having layout". We can use el.currentStyle.hasLayout to detect whether it has obtained layout. A universal method to obtain layout is zoom:1.
8. Strictly abide by the nesting rules of (x)html. The nesting rules are defined in the document type, and the document is parsed according to it. Although the current browsers are very eye-catching, in order to prevent them from getting crazy, it is better to be careful. In addition, although some elements will be closed automatically, we should close them ourselves. It is very important to develop good habits.
9. Improve your JavaScript skills
IE6 does not support many things or does not support them well, but we can use JavaScript to simulate almost all of them, such as various relationship pseudo-classes, sub-element filtering pseudo-classes, attribute pseudo-classes, target pseudo-classes, min-width and max-width, PNG transparency problem...
10. Come to my blog more often and try to make up round numbers for good luck. If I find any good stuff or bugs, I will report them to you as soon as possible~~~^_^