views:

83

answers:

4

How can I make a specific css stylesheet for internet explorer 8 ?

I mean, how can I load it only if the browser is IE8 ? (And not IE7 and IE6)

thanks

+2  A: 

You can use the following:

<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="ie8.css" media="screen" />
<![endif]-->
John McCollum
+2  A: 

use this

<!--[if IE 8]>
<link href="/stylesheets/iestyle8.css" rel="stylesheet" type="text/css" />
<![endif]--> 
red-X
+3  A: 
<!--[if IE 8]>
<link href="ie8.css" rel="stylesheet" type="text/css" />
<![endif]-->

http://www.quirksmode.org/css/condcom.html

meo
+1 for bothering to at least give the OP a link to more information (although just linking, rather than just a bit of text, isn't great form).
T.J. Crowder
@Patrick: If you really want **just** IE8, the above is fine. If you want IE8 *and later* (e.g., because you're using something new that will be continued in IE9, which isn't that far away), use `if gte IE 8` instead -- the difference is the `gte`, which is (of course) "greater than or equal".
T.J. Crowder
A: 

I'm having trouble thinking of a good reason for doing this. :p

reisio
No really. What's the good reason?
reisio
It's a safer way to deploy fixes for IE8's own rendering issues. While not as much of a headache as IE6, IE8 still has quirks that need to be corrected without having those corrections affect other browsers.
akamike
Can you name one?
reisio
That's what I thought.
reisio
@reisio, http://stackoverflow.com/questions/3114516/does-jquerys-fadein-and-fadeout-not-work-with-ie-8
Mike Sherov
@Mike Sherov: http://api.jquery.com/jQuery.browser/ and even without that, there'd be http://api.jquery.com/jQuery.support/ and even without that there'd be straight JavaScript detection and even without that you could do it with valid CSS and HTML only.
reisio