0

What's the matter with my conditional comments? They apply both to firefox and IE!

<!--[if IE 7]> <link rel="stylesheet" type="text/css" href="../App_Themes/css/stylesIE7.css" /> <![endif]--> 

Is this normal? Am I missing something?

3
  • How are you saying that the IE comments are visible to Firefox? Commented Jan 3, 2011 at 10:19
  • Your syntax looks just fine, so I would suspect there is something else above it that is incorrect. Can you narrow it down to the least reproducible code and post that for us to look at Commented Jan 3, 2011 at 10:27
  • I mean that css styles that should be loaded only in IE, are also loaded in firefox too Commented Jan 3, 2011 at 10:27

2 Answers 2

2

If by "visible" you mean they are visible in the source code, that is as designed. But Firefox will not be loading the CSS file, but treat the whole section as a comment. The syntax you use is correct.

Use e.g. Firebug's "Net" tab to confirm that the style sheet is in fact not being loaded.

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

5 Comments

by "visible" I mean that the css code that stylesIE7.css file contains, is applied to firefox too. I have used conditional comments a thousand times before, but this is the first time something this weird happens..
@ktsixit That's really strange. Can you show some code before and after the conditional comment? Are you sure there is no other unclosed comment in the document that might be causing the confusion? You don't happen to have this "IE tab" thing for Firefox activated?
I have never used something called "IE tab" in firefox, so I don't think that this is what causes the issue.
@ktsixit you have a second link to the same file underneath in line 52
I really don't understand where the second link came from. Let me check the code again please
1

In the source I see that you're including the stylesheets twice. Remove the last one.

 <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="App_Themes/trimar/stylesIE7.css" /> <![endif]--> <link href="App_Themes/trimar/styles.css" type="text/css" rel="stylesheet" /> <link href="App_Themes/trimar/stylesIE7.css" type="text/css" rel="stylesheet" /> 

3 Comments

I finally figured it out. My code was correct. I'm using nop-commerce in this website and it somehow loads automatically all css files included in css directory. I hadn't noticed that css file was loaded twice in source code though.
I moved stylesIE7.css file into another directory and it works fine now. Thank you all for your help
Is there any way to make it IE gt 9 & !IE?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.