On Nov 14, 2006, at 12:07 PM, Chris W. Parker wrote:
> Within CSS you can do the following to apply styles to IE only. (This
> hack may be fixed in IE7 not sure.)
>
> .header_b
> {
>       display: inline; /* non-IE */
>       _display: block; /* IE only */
> }
>
> Adding a '_' to any style makes all non-IE browsers ignore the rule.
>
> On the other hand if that will not work for you you'll need to do some
> simple object detection in your js code to detect an object that  
> only IE
> has. If the detection returns true you can have jQuery change the  
> style
> on '.header_b'.

I think the "preferred" method for targeting a browser for certain  
style rules is to include your main stylesheet first in the head  
element and then use conditional comments to include browser-specific  
stylesheets.

Examples:
1. This would serve up ie.css only to Internet Explorer:
<!--[if IE]>
   <link rel="stylesheet" href="/css/ie.css" type="text/css" />
<![endif]-->

2. This would serve up ie6andbelow.css only to Internet Explorer  
versions 6 and below:
<!--[if lt IE 7]>
   <link rel="stylesheet" href="/css/ie6andbelow.css" type="text/css" />
<![endif]-->

I'd recommend using CSS hacks as a last resort. Instead, if for some  
reason you can change the stylesheet, but not the HTML, you might  
want to consider using a child combinator, which IE6 and below would  
not be able to read. So you could do something like this:

.header_b {display: block;}
#some_parent_id > .header_b {display: inline;}  /* overwrites  
previous display:block in modern browsers */


___________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to