Hack -- compatibility test

Source: Internet
Author: User
Tags html header
CSS hack has different understandings of CSS parsing in different browsers, such as Internet Explorer 6, Internet Explorer 7, and Mozilla Firefox, which leads to different page effects, we cannot get the page effect we need. At this time, we need to write different CSS for different browsers so that they can be compatible with different browsers at the same time, so that we can get the desired page effect in different browsers. Because different browsers have different support for CSS and parse results, they also have a relationship with the priority of CSS. We can write different CSS for different browsers based on this. CSS hack has three forms: CSS class internal hack, selector hack, and HTML header reference (if IE) Hack. CSS hack mainly targets class internal hack: for example, IE6 can recognize underscores (_) and star numbers (*). IE7 can recognize asterisks (*) but cannot recognize underscores (_). Firefox cannot recognize both of them. Etc. selector hack: for example, IE6 can recognize * html. Class {}, IE7 can recognize * + html. Class {}, or *: First-Child + HTML. Class {}. Wait for HTML [1] header reference (if IE) Hack: For all IE: <! -- [If IE]> <! -- Your code --> <! [Endif] --> for IE6 and earlier versions: <! -- [If lt IE 7]> <! -- Your code --> <! [Endif] --> this type of hack not only takes effect for CSS, but also for all code written in the judgment statement. The writing order is generally to write the CSS of the browser with strong recognition ability in front. The following describes how to write more details. Select different browsers and versionsMinimize the use of CSS hack. Hack is risky and must be used with cautionUnless otherwise specified, the default runtime environment of all codes and examples in this document is standard. Some CSS hack browsers have cross-recognition, so it is necessary to implement hack for different browsers through layer-by-layer coverage. A few simple examples:* HTML. test {color: #090;}/* For IE6 and earlier */* + HTML. test {color: # ff0;}/* For IE7 */. test: Lang (zh-CN) {color: # f00;}/* For IE8 + and not ie */. test: Nth-Child (1) {color: # 0ff;}/* For ie9 + and not ie */internal attribute hackcss internal Attribute-level hack Syntax: Selector {Note: [2]No matter what method, the order of writing is firefox before writing, IE7 in the middle, IE6 at the end. Supplement: IE6 can recognize *, but cannot recognize it! Important and IE7 can recognize * and also! Important; FF cannot recognize *, but can recognize it! Important; Underline "_", IE6 supports underline, IE7 and Firefox do not support underline [2].

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.