Published 2012-02-01 12:24 by Leif Halvard Silli
In untarget specific browsers with style, I showed how to — eh — untarget browser with this method. But the same method and principle can be used to target specific browsers too.
<!--[if lte ie 7]><style>/*<![endif]-->
<style type="text/html" >/**/
p{color:red;}
</style>
For IE7 and below:
<style> tag.For all other browsers:
type attribute set to "text/html", all other browsers will ignore its content — it interpreted to not be CSS.The advantages are the same as for its twin sister — untarget specific browsers with style:
Like its twin sister, this method can be used for JavaScript as well:
<!--[if lte ie 7]><script>/*<![endif]-->
<script type="text/html">/**/ function n(){var i = "Hello World";document.write(i);}</script>
</head><body onload="n()">
There’s nothing to say — it works the same way as the CSS.
« To untarget specific browsers with style … | No condition comments before the DOCTYPE »
© 2013 Leif Halvard Silli