A css hack for IE7

Source: Internet
Author: User

IE7 has fixed many bugs and added support for some separators, therefore, hack for IE hiding or display, such as * HTML {} and HTML> body {}, will expire in IE7. Although CSS hack is not recommended, it is a foolproof filter, but it can only appear in HTML, and CSS hack is useful. Nanobot found some CSS hack for IE7, specifically:

> Body
HTML *
* + Html

The first two are invalid CSS statements, which are ignored in standard compatible browsers, but not in IE7. For> body, it will replace the missing selector with the global selector *, that is, it will be processed as *> body, and not only for> selector, + ,~ This phenomenon also exists in the selector. For HTML *, because there is no space between HTML and *, it is also a CSS syntax error, but IE7 does not ignore it, but mistakenly considers there is a space here. For the third type of * + HTML, IE7 considers that the DTD declaration before HTML is also an element, so HTML will be selected. Among the three methods, only this method is legal CSS writing, that is to say, it can be verified by the validator, so it is also the hack usage recommended by the author.

Finally, the author provides the best method:

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 more information, see the original article: 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.