Using Conditional Comments

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]-->

This article was ported from an older CMS, and comments were purposefully lost in the migration. If some were found most relevant, I pasted them to the bottom of that post. No new comments are accepted on these older articles.

Comments are closed.