Forum Moderators: open

Message Too Old, No Replies

IE conditional comments not working

picks up css for a split second only

         

maree_dw

1:44 am on Jun 6, 2008 (gmt 0)

10+ Year Member



I am trying to use conditional comments to fix some problems in IE but for some reason explorer picks it up for a split second then resumes back to the master css.

I am using this code in the html header

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

I have removed all threats of a specificity problem.

Any suggestions?

surrealillusions

10:36 am on Jun 6, 2008 (gmt 0)

10+ Year Member



Have you tried putting the conditional comments after the usual link to the CSS? And are you using IE6? As that comment is for ie6 only, not any other version.

:)

maree_dw

11:32 pm on Jun 9, 2008 (gmt 0)

10+ Year Member



Hi,

I just moved the comment to after the css link (it was above it before). Now it doesnt flash up with the cl_ie6.css. But still just displays the master css.

We have ie6 on one computer and ie7 on another. i have tried it on both (changing the comment to IE 7) but no success.

penders

10:25 am on Jun 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



To target IE6, it would be more usual to use:
<!--[if IE 6]>

...rather than specifying a minor version (.0) as well. Not sure if that will make any difference though.

Does your CSS validate OK? Any error could prevent the CSS from being parsed and hence would not be applied?

maree_dw

10:40 pm on Jun 11, 2008 (gmt 0)

10+ Year Member



Hi there,

Yep ive tried using just 6 instead of 6.0 with no luck! and my css validates ok.

very frustrating!

encyclo

11:53 pm on Jun 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld maree_dw. :) As you seem to have the syntax right for the conditional comments, I believe the problems is that the conditional comments are working, but they are not having the effect you think they will have. ;) You mention this:

But still just displays the master css.

The usual setup is that you call the master CSS file first, and that file contains rules for all browsers, including IE. Then you can use a conditional comment to call a second file just for IE, in which there are rules which are parsed in addition to the master CSS file. It in no way replaces the master CSS file, although in terms of specificity, it can be used to override previously-declared rules. Is this your expectation?

maree_dw

3:55 am on Jun 12, 2008 (gmt 0)

10+ Year Member



Ahh.. now thats starting to make sense. I thought maybe this might have happened and tried the !important rule in the second css for certain things but that didnt work. what is involved in overriding previous rules of the master?

penders

6:20 am on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



what is involved in overriding previous rules of the master?

Redeclare them. In the same way that styles defined later in a stylesheet override styles defined before it - the cascade.

An IE-only stylesheet would generally be very small - only overriding the styles that it needs to.

jalarie

8:41 pm on Jun 17, 2008 (gmt 0)

10+ Year Member



If you specify a minor release, you need a four-digit number:

<!--[if IE 6.0000]>