A CSS Hack for IE7

Source: Internet
Author: User
Css

IE7 fixes a lot of bugs and also adds support for some selectors, so now the hack, such as *html {} and html>body {} so on IE hidden or displayed, will fail in IE7. Although CSS Hack is not recommended, conditional annotations are foolproof filters, but conditional annotations can only appear in HTML, CSS Hack is still useful. Nanobot found some CSS Hack for IE7, specifically:

>bodyhtml**+html

These three kinds of writing, the first two are illegal CSS writing, in the standard compatible browser is ignored, but IE7 do not think so. For >body that, it replaces the missing selector with the global selector, which means it is * processed *>body , and not only for the > selector, but also for +,~ the selector. For html* , because there is no space between HTML and *, it is also a kind of CSS syntax error, but IE7 will not ignore, but mistakenly think there is a space. For the third *+html , IE7 that html the preceding DTD declaration is also an element, so the HTML is selected, and this is the only method in the three methods that is valid for CSS writing, that is, it can be validated by a validator, and therefore is the hack usage recommended by the author.

Finally, the author gives the best way:

IE 6 and below
Use to * html {} Select the HTML element.
IE 7 and below
Use to *+html, * html {} Select the HTML element.
IE 7 only
Use to *+html {} Select the HTML element.
IE 7 and modern browsers only
Use to select the body html>body {} element.
Modern browsers only (not IE 7)
Use to select the body
html>/**/body {} element.

Specific information Reference original: EasyCSS hacks for IE7



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.