CSS Validation

Discussion in 'HTML' started by Jim Royal, Jul 22, 2003.

  1. Jim Royal

    Jim Royal Guest

    I'm rewriting the code on my site for table-less CSS layout. I'm proud
    to say that both my page template HTML and CSS validates. However, I
    receive the following warning on the CSS:

    You have no color with your background-color : body
    You have no background-color with your color : h1, h2, p, li, etc...

    I thought the purpose of cascading style sheets was that they cascade
    -- that if you set the background-color in a parent selector, all child
    selectors inherit it. So why the warning? Is there really any purpose
    in explicitly defining the background for all my other selectors as
    transparent?

    --
    Jim Royal
    "Understanding is a three-edged sword"
    http://JimRoyal.com
     
    Jim Royal, Jul 22, 2003
    #1
    1. Advertising

  2. Jim Royal

    Steve Pugh Guest

    Jim Royal <> wrote:

    >You have no color with your background-color : body
    >You have no background-color with your color : h1, h2, p, li, etc...
    >
    >I thought the purpose of cascading style sheets was that they cascade
    >-- that if you set the background-color in a parent selector, all child
    >selectors inherit it.


    That's not cascading. That's inheritence. Cascading is the combining
    of styles from multiple stylesheets (e.g. an author stylesheet, a
    user one and the UA default one) to create the final style.

    >So why the warning?


    A user may have a stylesheet that sets a background colour for H1. Or
    the browser default may not be what you expect. Assuming that it will
    inherit the body background-color is then dangerous. So _always_ set
    both background and foreground colours together. Relying on the values
    'transparent' or 'inherit' can be risky and if used they must be
    hidden from NN4.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Jul 22, 2003
    #2
    1. Advertising

  3. Jim Royal wrote:
    > I'm rewriting the code on my site for table-less CSS layout. I'm proud
    > to say that both my page template HTML and CSS validates. However, I
    > receive the following warning on the CSS:
    >
    > You have no color with your background-color : body
    > You have no background-color with your color : h1, h2, p, li, etc...
    >
    > I thought the purpose of cascading style sheets was that they cascade
    > -- that if you set the background-color in a parent selector, all child
    > selectors inherit it. So why the warning? Is there really any purpose
    > in explicitly defining the background for all my other selectors as
    > transparent?


    No, as transparent is the standard anyway. That's why it is a "warning"
    only, not a mandate. Just so you make sure that you didn't "forget" the
    background-color of a parent selector which would make the content
    unreadable.
    --
    Nicolai Zwar
    http://www.nicolaizwar.com
    (we're late, we know, and we're still closed)
     
    Nicolai P. Zwar, Jul 22, 2003
    #3
  4. In article <>,
    says...
    > Jim Royal <> wrote:
    >
    > >You have no color with your background-color : body
    > >You have no background-color with your color : h1, h2, p, li, etc...
    > >

    ....
    > >So why the warning?

    >
    > A user may have a stylesheet that sets a background colour for H1. Or
    > the browser default may not be what you expect. Assuming that it will

    ....

    Whilst I agree, I must say that anyone with a user stylesheet that sets
    a background color without setting a foreground color deserves whatever
    they get...
     
    Jacqui or (maybe) Pete, Jul 22, 2003
    #4
  5. Jim Royal

    Steve Pugh Guest

    Jacqui or (maybe) Pete <> wrote:
    >In article <>,
    >says...


    >> A user may have a stylesheet that sets a background colour for H1. Or
    >> the browser default may not be what you expect. Assuming that it will

    >
    >Whilst I agree, I must say that anyone with a user stylesheet that sets
    >a background color without setting a foreground color deserves whatever
    >they get...


    The user can have both set and the problem will stil arise.

    If I have
    H1 {color: foo; background: bar}
    in my user stylesheet and you have
    H1 {color: bar;}
    in your author stylesheet, then I get my background and your
    foreground. Whoops.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Jul 22, 2003
    #5
  6. Jim Royal

    Steve Pugh Guest

    "Nicolai P. Zwar" <> wrote:
    >Steve Pugh wrote:
    >
    >> A user may have a stylesheet that sets a background colour for H1.

    >
    >But users actually surfing with their own stylesheets usually have far
    >more things changed than just the background color for H1.


    True, but it only takes one rule out of many to create a problem.

    >> Or
    >> the browser default may not be what you expect. Assuming that it will
    >> inherit the body background-color is then dangerous.

    >
    >Only if the browser doesn't interpret the CSS rules correctly.


    I hope that you're obliquely pointing out my error in that the initial
    value of backgrond-color is transparent and not initial. I can't think
    what else you mean.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Jul 22, 2003
    #6
  7. Jim Royal

    Jim Royal Guest

    Thanks for the feedback. I'll take it all under advisement.

    --
    Jim Royal
    "Understanding is a three-edged sword"
    http://JimRoyal.com
     
    Jim Royal, Jul 22, 2003
    #7
  8. In article <>, Nicolai P. Zwar wrote:
    > Steve Pugh wrote:
    >
    > > A user may have a stylesheet that sets a background colour for H1.

    >
    > But users actually surfing with their own stylesheets usually have far
    > more things changed than just the background color for H1.


    Sure, they have also color for h1, but it won't help as it is overridden.

    > > Or
    > > the browser default may not be what you expect. Assuming that it will
    > > inherit the body background-color is then dangerous.

    >
    > Only if the browser doesn't interpret the CSS rules correctly.


    Is there some reason why browsers default value for color/background-
    color for h1 need to be inherit? I see no reason why browsers default
    couldn't be some other color. And with Opera you can change default color
    of H1 from preferences, not knowing anything about CSS.


    --
    Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
    Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
    tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.
     
    Lauri Raittila, Jul 22, 2003
    #8
  9. In article <>, Nicolai P. Zwar wrote:

    > No, as transparent is the standard anyway. That's why it is a "warning"
    > only, not a mandate. Just so you make sure that you didn't "forget" the
    > background-color of a parent selector which would make the content
    > unreadable.


    No, that's not so, as others explained. You can't trust inheritance, nor
    color of containing block. Don't count on them, unless you have no choise


    --
    Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
    Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
    tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.
     
    Lauri Raittila, Jul 22, 2003
    #9
  10. Steve Pugh wrote:
    > "Nicolai P. Zwar" <> wrote:
    >
    >>Steve Pugh wrote:
    >>
    >>
    >>>A user may have a stylesheet that sets a background colour for H1.

    >>
    >>But users actually surfing with their own stylesheets usually have far
    >>more things changed than just the background color for H1.

    >
    >
    > True, but it only takes one rule out of many to create a problem.


    Also true, but if you are surfing with your own stylesheet and have only
    ONE thing -- e.g. color for H1 -- changed, then you're doing it on your
    own risk.

    >>>Or
    >>>the browser default may not be what you expect. Assuming that it will
    >>>inherit the body background-color is then dangerous.

    >>
    >>Only if the browser doesn't interpret the CSS rules correctly.

    >
    >
    > I hope that you're obliquely pointing out my error in that the initial
    > value of backgrond-color is transparent and not initial.


    Well, we are talking about "background-color: transparent;" all along.
    Of course, if you want to use anything else, you're better off
    specifying it.

    > I can't think
    > what else you mean.


    I mean that <body style="background-color: yellow;"><h1 style="color:
    blue;"> should give you a blue headline on a yellow ground (unless other
    rules specifically override this), because H1 background is transparent,
    unless anything else is specifically requested.

    --
    Nicolai Zwar
    http://www.nicolaizwar.com
    (we're late, we know, and we're still closed)
     
    Nicolai P. Zwar, Jul 22, 2003
    #10
  11. In article <>,
    says...
    > Jacqui or (maybe) Pete <> wrote:
    > >In article <>,
    > >says...

    >
    > >> A user may have a stylesheet that sets a background colour for H1. Or
    > >> the browser default may not be what you expect. Assuming that it will

    > >
    > >Whilst I agree, I must say that anyone with a user stylesheet that sets
    > >a background color without setting a foreground color deserves whatever
    > >they get...

    >
    > The user can have both set and the problem will stil arise.

    ....

    Ah, yes. I was having a 'Homer' moment, and we're not talking blind
    greek poets here...
     
    Jacqui or (maybe) Pete, Jul 22, 2003
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Colin Mackay
    Replies:
    0
    Views:
    2,698
    Colin Mackay
    Jun 25, 2003
  2. Libs
    Replies:
    0
    Views:
    1,508
  3. Colin Basterfield

    Web form validation vs object validation

    Colin Basterfield, Nov 28, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    430
    Tommy
    Nov 29, 2003
  4. Matt
    Replies:
    14
    Views:
    4,114
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  5. Lucas Tam
    Replies:
    2
    Views:
    1,121
    Lucas Tam
    Feb 26, 2004
Loading...

Share This Page