A CSS Hack_ experience exchange for IE7

Source: Internet
Author: User

IE7 fixes many bugs and adds support for some selectors, so hack that are hidden or displayed for IE, such as *html {} and Html>body {}, will expire in IE7. Although CSS Hack is not recommended, conditional annotations are foolproof filters, but conditional annotations can only appear in HTML, and CSS Hack are useful. Nanobot found some CSS Hack for IE7, specifically:

>body
html*
*+html

These three kinds of writing, the first two are illegal CSS wording, in the standard compatible browser is ignored, but IE7 not think so. For >body, it replaces the missing selector with the global selector *, which is the process of *>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 CSS syntax error, but IE7 will not ignore it, but mistakenly think there is a space. For the third kind of *+html,ie7 that the DTD declaration in front of HTML is also an element, so the HTML will be selected, the three methods only this method is a valid CSS notation, that is, can be verified by the validator, and therefore also the author recommended hack usage.

Finally, the author gives the best way:

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

For specific information, refer to the original: Easy CSS 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.