css| Tips
15. Importing (import) and hiding CSS
Since older browsers do not support CSS, a common practice is to use the @import technique to hide the CSS. For example:
@import URL (main.css);
However, this method does not work for 4, which makes me very headache for a while. Later I used the following wording:
@import main.css;
This can also be hidden in the IE4 CSS, hehe, also saved 5 bytes. To learn more about @import syntax, see here "Centricle ' CSS Filter Chart"
16. For IE optimization
There are times when you need to define some special rules for IE bugs, there are too many CSS tips (hacks), and I use only two of these methods, and whether or not Microsoft is better at supporting CSS in the upcoming IE7 Beta, both of these are the safest.
- 1. Method of annotation
- (a) to hide a CSS definition in IE, you can use the selector (child-selector):
Html>body p {
/* Definition Content * *
}
- (b) The following wording is only understandable by IE browser (hidden from browser)
* HTML P {
* Declarations * *
}
- (c) There are times when you want Ie/win to be effective and ie/mac hidden, and you can use the backslash technique:
/* */
* HTML P {
Declarations
}
/* */
- 2. Method of conditional annotation (conditional comments)
Another way, I think, than the CSS hacks more withstand the test is the use of Microsoft's private attribute condition annotation (conditional comments). In this way you can define some styles for IE without affecting the definition of the main style sheet. Just like this:
<!--[If ie]>
<link rel=stylesheet type=text/css href=ie.css/>
<! [endif]-->