Ask the CSS Guy

Using Conditional Comments to Serve Different Styles to IE6 and IE7

When needing to serve styles to certain versions of Internet Explorer, use conditional comments. Multiple conditional comments can be used.

This following code shows possible usage, with a demo page as well:

<style type="text/css">
p {font:bold 12px/17px arial;}
p.colordependency {background:cyan;}
</style>

<!--[if IE]>
<style type="text/css">
p.hidefromIE {display:none;}
</style>
<![endif]-->

<!--[if IE 6]>
<style type="text/css">
p.hidefromIE6 {display:none;}
</style>
<![endif]-->

<!--[if lte IE 6]>
<style type="text/css">
p.colordependency {background:red;}
</style>
<![endif]-->

<!--[if IE 7]>
<style type="text/css">
p.hidefromIE7 {display:none;}
p.colordependency {background:yellow;}
</style>
<![endif]-->

Comments (1)

excellency said:

thank you for its article

 

Post a comment