Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    37
    Thanks
    11
    Thanked 1 Time in 1 Post

    New help with validation

    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:

    Code:
    <!--[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:

    Code:
    <!--[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.

  • #2
    New Coder
    Join Date
    Aug 2009
    Posts
    37
    Thanks
    11
    Thanked 1 Time in 1 Post
    Code:
    <!--[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.
    Code:
    <!--[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:
    Code:
    <!--[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.
    Last edited by rogierius; 06-10-2010 at 02:26 PM. Reason: Very confusing this

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    Code:
    <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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •