SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: CSS Validation

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Location
    Utrecht (Netherlands, the)
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS Validation

    When would you say a stylesheet is W3C valid?

    I tried to validate a stylesheet and got a bunch of warnings about colors and redefinitions. I'm definitely not going to solve those, since that would only mean extra code with the exact same effect in the end, i.e. useless code.

    There are no errors, so basically the sheet is valid. But is it W3C valid with warnings?
    Hippopotomonstrosesquippedaliophobia - Fear of long words

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd say its valid when it passes through this OK - http://jigsaw.w3.org/css-validator/

    It's important to remember that the CSS won't be valid if the XHTML page it is applied to is not fully valid!

    Validating a style sheet should not require any extra code, just a redo of the stuff you already have in there.

    a number of CSS hacks will also result in an invalid CSS file (such as using the zoom property) - if you use invalid hacks it could be a good idea to separate them out into there own stylesheet - that way at least your main one is good ;>

    hope this all helps!

  3. #3
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by CadmiumNL
    When would you say a stylesheet is W3C valid?
    When the validator tells me so ;-)

    I tried to validate a stylesheet and got a bunch of warnings about colors and redefinitions.
    Warnings are just that - usually occurs when you don't define background colors for various elements.

    There are no errors, so basically the sheet is valid. But is it W3C valid with warnings?
    I would say yes because the validator itself passes the page. It is only telling you of the warnings, it is up to you whether to go back and correct these warnings, they have no bearing on the actual validation.

    Nadia

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Location
    Utrecht (Netherlands, the)
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rossbruniges
    if you use invalid hacks it could be a good idea to separate them out into there own stylesheet
    I haven't had any problems with that so far, but it's a good idea nonetheless. I guess the same thing goes for mozilla css extensions and IE filters as well.

    Quote Originally Posted by Nadia P
    When the validator tells me so ;-)
    That's just it. It doesn't . All it tells is that it either has errors and warnings, only warnings or no errors and warnings. Not if the sheet passed the test or not, like with the html validation.

    I'll leave the warnings as they are and simply take them as pointers where things might go different than expected.

    Thanks, guys!!
    Hippopotomonstrosesquippedaliophobia - Fear of long words

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    http://jigsaw.w3.org/css-validator/v...iteguru.co.uk/ tells me ...

    Congratulations!

    Valid CSS! This document validates as CSS!

    ... yet it also tells me ...

    Warnings
    URI : http://www.siteguru.co.uk/sg_styles.css

    * Line : 87 (Level : 1) You have no background-color with your color : A:link
    * Line : 93 (Level : 1) You have no background-color with your color : A:visited
    * Line : 99 (Level : 1) You have no background-color with your color : A:hover
    * Line : 105 (Level : 1) You have no background-color with your color : A:active
    * Line : 170 (Level : 2) Redefinition of voice-family : #bottomcontainer
    etc.

    Ian Anderson
    www.siteguru.co.uk

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Location
    Utrecht (Netherlands, the)
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only time it says that is when validating by url. Since I'm working on an IntraNet, that doesn't work for me. When validating by file upload or direct input, it does not give you that message .
    Hippopotomonstrosesquippedaliophobia - Fear of long words

  7. #7
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If it gives you errors then it's invalid.

    If it doesn't give you errors then it's valid.

    The warnings are really just to remind you to check that whatever they're talking about won't be an issue on your page - they don't fail your CSS
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project

  8. #8
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    USA
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To work as intended, your CSS style sheet needs a correct document parse tree. This means you should use valid HTML.

    Warnings

    URI : file://localhost/xhtml.css

    • Line : 13 (Level : 1) You have no background-color with your color : form
    • Line : 20 (Level : 1) You have no background-color with your color : img
    • Line : 27 (Level : 1) You have no background-color with your color : a
    • Line : 34 (Level : 1) You have no background-color with your color : a img
    • Line : 41 (Level : 1) You have no background-color with your color : a:link
    • Line : 47 (Level : 1) You have no background-color with your color : a:visited
    • Line : 53 (Level : 1) You have no background-color with your color : a:active
    • Line : 70 (Level : 1) You have no background-color with your color : #template
    • Line : 76 (Level : 1) You have no background-color with your color : #header
    • Line : 82 (Level : 1) You have no background-color with your color : #footer
    • Line : 91 (Level : 1) You have no background-color with your color : #navigation ul li
    • Line : 91 (Level : 1) You have no background-color with your color : #navigation ul li


    Valid CSS information


    • body {
      • color : black;
      • background : white;
      • font-family : verdana, arial, sans-serif;
      • font-size : 10px;
      • margin : 0;
      }
    • form {
      • margin : 0;
      • color : inherit;
      • background : transparent;
      }
    • img {
      • border : none;
      • color : inherit;
      • background : transparent;
      }
    • a {
      • text-decoration : none;
      • color : inherit;
      • background : transparent;
      }
    • a img {
      • border : none;
      • color : inherit;
      • background : transparent;
      }
    • a:link {
      • background : transparent;
      • color : blue;
      }
    • a:visited {
      • background-color : transparent;
      • color : blue;
      }
    • a:active {
      • background-color : transparent;
      • color : blue;
      }
    • a:hover {
      • background-color : yellow;
      • color : red;
      }
    • a:visited:hover {
      • background-color : yellow;
      • color : red;
      }
    • #template {
      • color : inherit;
      • background : transparent;
      }
    • #header {
      • color : inherit;
      • background : transparent;
      }
    • #footer {
      • color : inherit;
      • background : transparent;
      }
    • #navigation ul, #navigation ul li {
      • margin : 0;
      • display : inline;
      • list-style : none;
      • color : inherit;
      • background : transparent;
      }
    I DONT GET IT!!!!!

  9. #9
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I DONT GET IT!!!!!
    What don't you get exactly?

    Nadia

  10. #10
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    USA
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Nadia P
    What don't you get exactly?

    Nadia
    i have background-color or background and it still says i don't.

  11. #11
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by worldburns2death
    i have background-color or background and it still says i don't.
    It's the background: transparent; it doesn't like or recognise. Changing it to an actual, will remove the warning.....

    I admit I've used transparent myself, and don't really worry too much about the warnings ;-)

    Nadia

  12. #12
    SitePoint Enthusiast dziner's Avatar
    Join Date
    Jun 2004
    Location
    Harrisburg
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is also something that bugs me. I'd like my css to validate but I keep the same warning:

    Invalid number : background-color tranparent is not a color value : tranparent
    If I don't specify a "background color" for an element that I specify a "color", then it gives me an error. If I specify it as "transparent", then I get a warning. I'd like to get rid of both but can't seem to find a way to do that. Any suggestions or fixes for this?

  13. #13
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ignore it. If it produces a warning, all it's saying is that it *might* cause some problems, not that it will.

    Another thing you can do is to set the background color to be the same as the background color of the parent container.


Bookmarks

Posting Permissions

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