Re: CSS Troubles - Redefinition of background-color : BODY?

by =?iso-8859-1?Q?St=E9phane?= Bergeron <stephberg(at)videotron.ca>

 Date:  Fri, 16 Jun 2000 16:45:18 -0400
 To:  hwg-techniques(at)hwg.org
 Cc:  "Smokin' Dave" <smokindave(at)smokindave.com>
 References:  hotmail
  todo: View Thread, Original
At 11:00 AM 16/06/00 -0500, you wrote:
>Just uploaded a style sheet for validation at the w3c site, and keep=20
>getting the same "error" message, which reads, "Redefinition of=20
>background-color : BODY". This is obviously referring to the BODY=20
>definitions, and i assumed it was referring to repeated styles, but=20
>removing the repeated ones didn't seem to help either. Can anybody here=20
>make wind of it? By the way, the style sheet isn't completely done, as I=20
>still need to finish redefining the font styles. That, I have no problem=20
>with, but I'm still trying to figure out the above message. The style=20
>sheet is as follows:
>
>
>  BODY {
>    background : url(bg1.gif);
>    color : #000000;
>    background-color : #ffffff;
>}

The problem is that you have two declarations for background, one uses the=
=20
shorthand syntax (the first one) and the other is setting the background=20
color itself.  To solve this you could rewrite this style rule one of two=20
ways.  Personally I'd use the shorthand syntax and go with:

BODY {
         background: url(bg1.gif) #ffffff;
         color: #000000;
}

There's only a space between url(bg1.gif) and #ffffff.  The second way=20
would be:

BODY {
         background-image: url(bg1.gif);
         background-color: #ffffff;
         color: #000000;
}

The CSS Validator flagged a problem because the way you had written the=20
style rules, you were trying to define the same background property twice=20
(background-color).  Using shorthand syntax (like you had done on your=20
first line) sets background properties values for every property that can=20
be set.  If you don't explicitly declare one, the browser uses a default=20
one but it's still considered already set.  That's why the Validator choked=
=20
on the background-color declaration.

HTH!

St=E9phane Bergeron

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA