views:

141

answers:

5

How to i can use this

    <!--[if lt IE 8]>
    <style type='text/css'>
  #header ul#h-menu li a{font-weight:normal!important}
    </style>
    <![endif]-->

if i remove <!--[if lt IE 8]><![endif]--> Above code 'll run good in IE 8 but if i dont it dont run. Help me with fixed IE, if i want in above code in all IE version,.

i want code #header ul#h-menu li a{font-weight:normal!important} run only in IE

+7  A: 

If you want this to work in IE 8 and below, use

<!--[if lte IE 8]>

lte meaning "Less than or equal".

For more on conditional comments, see e.g. the quirksmode.org page.

Pekka
And it might be a good practice to only put a reference to an external stylesheet in your conditional comment. Better readability in my opinion.
Justus Romijn
@Justus: And better cacheability along with smaller HTML source code, too.
Tomalak
+2  A: 

How about

<!--[if IE]>
...
<![endif]-->

You can read here about conditional comments.

Boldewyn
this will work because it will trigger all versions of IE. However you may prefer to use the `lte IE 8` version because you may not want it running in IE9.
Spudley
OP asked for "only in IE", without further specification. Otherwise, yes, the `lte IE8` would be most surely better.
Boldewyn
A: 
    <!--[if IE]>
    <style type='text/css'>
    #header ul#h-menu li a{font-weight:normal!important}
    </style>
    <![endif]-->

will apply that style in all versions of IE.

Bobby Jack
+3  A: 
<!--[if lt IE 8]><![endif]-->

The lt in the above statement means less than, so 'if less than IE 8'.

For all versions of IE you can just use

<!--[if IE]><![endif]-->

or for all versions above ie 6 for example.

<!--[if gt IE 6]><![endif]-->

Where gt is 'greater than'

If you would like to write specific styles for versions below and including IE8 you can write

<!--[if lte IE 8]><![endif]-->

where lte is 'less than and equal' to

Rocket Ronnie
+2  A: 

[if lt IE 8] means "if lower than IE8" - and thats why it isn't working in IE8.

wahat you want is [if lte IE 8] which means "if lower than or equal IE8".

oezi