PDA

View Full Version : New help with validation



rogierius
06-10-2010, 01:47 PM
I'm finishing up my coding and putting it through the Markup Validation.

But I have a problem with my coding in my header and multiple css files:




<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="../../css/ie6-and-down.css" />
<![endif]-->

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

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

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


The validator goes completely berserk with IF commands.

When I code it like this, validator is happy again, but then the different style sheets are ignored:




<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="../../css/ie6-and-down.css" />
<![endif]-->

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

<link rel="stylesheet" type="text/css" href="../../css/css_stylesheet.css" />



Does anybody know a solution to get good coding and the use of multiple stylesheets?
It's driving me nuts.

rogierius
06-10-2010, 01:57 PM
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie6-and-down.css"" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie7.css" />
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="css/css_stylesheet.css" />
<![endif]-->
<!--[if !IE]>
<link rel="stylesheet" type="text/css" href="css/css_stylesheet.css" />
<![endif]-->

Validates perfectly, IE6, IE7 en IE8 views fine, but Firefox has not styling. Firefox is not directed to the general stylesheet. What to do?

But to fix the firefox problem, I need to add <!--> so other browsers see the stylesheet. But then, the validator marks it as wrong.

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

How to change it so everything works and validators is happy too?

Found it:

<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie6-and-down.css"" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie7.css" />
<![endif]-->
<!--[if gt IE 7]>
<link rel="stylesheet" type="text/css" href="css/css_stylesheet.css" />
<![endif]-->
<!--[if !IE]><!-->
<link rel="stylesheet" type="text/css" href="css/css_stylesheet.css" />
<!--<![endif]-->

Sorry for all the fuss.

_Aerospace_Eng_
06-10-2010, 02:10 PM
This is kind of backwards. The IE only stylesheets are supposed to come after the main stylesheet and override any styles that need to be different for IE.

<link rel="stylesheet" type="text/css" href="css/css_stylesheet.css" />
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie6-and-down.css"" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie7.css" />
<![endif]-->

Try that instead. Firefox and IE8 will get the main stylesheet then your other stylesheets will take over. Any non-IE browser doesn't understand normal conditional comments. Also the validator has no idea about what is in the conditional comments, it just sees the conditional comments as normal comments.