-1

I'm having a strange issue.

I am using Internet explorer 9 and just changing the browser mode to IE 7 or IE 8 etc ...

My problem is that I've added:

<!--[if lt IE 7]>
<link type=\"text/css\" rel=\"stylesheet\" href=\"/styles/ie7.css\" />
<![endif]-->

but it's not changing to the conditional css file when in IE9 's IE7 browser mode...

Is this normal?

2
  • 3
    lt IE 7 will never match IE7! Commented Apr 27, 2012 at 14:11
  • Why would you need to manually switch IE9 into IE7 mode? Write your website to use IE9's standards mode and let the IE7 stylesheet only be used in IE7. Commented Apr 27, 2012 at 14:15

2 Answers 2

9

if lt IE 7 will match IE6 (or lower).

To match IE7, use lte (less than or equal)

Sign up to request clarification or add additional context in comments.

Comments

2

@SLaks is right about the error you are receiving.


I would like to add to that by showing you a better way to target IE:

<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]><html class="ie6" lang="en"><![endif]-->
<!--[if IE 7 ]><html class="ie7" lang="en"><![endif]-->
<!--[if IE 8 ]><html class="ie8" lang="en"><![endif]-->
<!--[if IE 9 ]><html class="ie9" lang="en"><![endif]-->
<!--[if IE 10 ]><html class="ie10" lang="en"><![endif]-->
<!--[if !IE ]><!--><html class="non-ie" lang="en"><!--<![endif]-->

The benefit of doing it this way is that you get to keep the best practice of only using 1 stylesheet. You simply preface your target with the corresponding IE class you want to hack.

For example: .ie6 #target-id


For a more in depth explanation, check out Paul Irish's article:

Conditional stylesheets vs CSS hacks? Answer: Neither!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.