The syntax for conditional comments is as follows:
- Positive
- Negative
HTML
condition is one of the following:
IE- Any version of IE
lt IE version- Versions less than version
lte IE version- Versions less than or equal to version
IE version- Only version version
gte IE version- Versions greater than or equal to version
gt IE version- Versions greater than version
version is the version of Internet Explorer, typically 5, 5.5, 6, or 7
for example:
Test
Test
****In-css hack
body[class|="page-body"]
The CSS 2.1 specification isn't clear about whether or not a hyphen can be included in the value of a hyphen-separated attribute selector. Most browsers, including Firefox and Internet Explorer 7, Allow the body[class|="page-body"] selector to select an element whose start tag looks like this: . However, Opera interprets the specification differently in this regard. It splits up the attribute value by hyphens and only checks the first piece against the attribute selector value. Obviously, if the attribute was split by hyphens, the first piece won't have any hyphens in it, so Opera treats this selector as a non-match. Therefore, when the proper class is applied to the body element, this selector matches Internet Explorer 7 and most modern browsers except Opera. Opera may change their behavior to match other browsers in the future, but this technique is known to work for Opera 8 and 9.
Here is an example of this technique in use:
Test p { background: red; /* Applies to all major browsers */ } body[class|="page-body"] p { background: green; /* Applies to IE 7 and most modern browsers except Opera */ } Test
|
| Unrecommended hacksIf you are going to use hacks, the above techniques are the recommended choices. However, it's interesting to point out the following unrecommended hacks. Some of them rely on invalid CSS or are more clumsy than the above alternatives. |
No comments:
Post a Comment