Content deleted Content added
m →Star HTML hack: Closing the comment |
No edit summary |
||
Line 1:
A '''CSS filter''' is a coding technique that aims to effectively hide or show parts of the [[Cascading style sheets|CSS]] to different [[Web browser|browsers]], either by exploiting CSS-handling quirks or bugs in the browser or by taking advantage of lack of support for parts of the CSS specifications. Using CSS filters, some designers have gone as far as delivering entirely different CSS to certain browsers in order to ensure that designs are rendered as expected. Because very early web browsers either were completely incapable of handling CSS or rendered CSS very poorly, designers today often routinely use CSS filters that completely prevent these ancient browsers from 'seeing' any of the CSS. For example, CSS filters are very often put in place to exclude Netscape 4.xx and Internet Explorer 4, ensuring that only more recent 'v5' browsers 'see' the CSS.
=== Conditional Comments ===
Conditional Comments are
There are two types of conditional comment, downlevel revealed which is a proprietary Microsoft HTML tag and downlevel hidden which are ignored by non Microsoft browsers because they are treated as a standard comment.
Conditional comments can be used to hide certain styles from a specific browser, or even to supply a tailored style sheets for individual browser versions.
This is an example of downlevel hidden conditional comment:
<pre>
<!--[if IE 7]>
Line 9 ⟶ 15:
<![endif]-->
</pre>
This is an example of downlevel revealed conditional comment:
<pre>
<![if !IE]>
<style type="text/css">
p {text-decoration:line-through; /* line-through paragraph text in browsers other than Internet Explorer */}
</style>
<![endif]>
</pre>
=== "Hacks" ===
"Hacks" are style definitions that exploit known peculiarities and bugs to control whether style rules are seen by a specific browser version. Care should be taken when using hacks, website authors should check that hacks still work as intended when new version of browsers are released.
==== Selector Hacks ====
===== Star HTML hack =====
Line 21 ⟶ 40:
Internet Explorer does not support the "child selector" (<code>></code>), allowing rules to be specified for all browsers except Internet Explorer. For example:
<pre>html>body p {color: blue; /* Turns paragraph text blue in Firefox, but not in IE */}</pre>
==== Criticisms of Hacks ====
Hiding code using hacks often leads to pages being incorrectly displayed when browsers are updated. Many Hacks that used to hide CSS from Internet Explorer 6 and lower will not work in Internet Explorer 7 due to Internet Explorer 7 improved support for CCS standards. The Microsoft Internet Explorer development team have asked that people use conditional comments instead[http://blogs.msdn.com/ie/archive/2005/10/12/480242.aspx] of hacks.
== External links ==
|