HighDots Forums  

Writing Valid CSS (help)

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Writing Valid CSS (help) in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
eomer
 
Posts: n/a

Default Writing Valid CSS (help) - 12-12-2005 , 06:44 PM






Hi, I trying to validate myy CSS using
http://jigsaw.w3.org/css-validator/. I get back some errors, but I
don't understand them. I will leave you with the errors and then the
CSS. Thanks in advance.

Line : 24 (Level : 1) You have no background-color with your color :
div.navigationItem a
Line : 29 (Level : 1) You have no color with your background-color :
div.navigationItem a:link


div.navigationItem a {
display: block;
font-weight: bold;
text-decoration: none;
text-align: right;
letter-spacing: 1px;
margin: 0px;
color: blue; /* THIS IS LINE 24 */
border-top: 1px solid black;
}

div.navigationItem a:link{
background: white; /* THIS IS LINE 29 */
text-decoration: none;
}


Reply With Quote
  #2  
Old   
Beauregard T. Shagnasty
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-12-2005 , 07:15 PM






eomer wrote:

Quote:
Hi, I trying to validate myy CSS using
http://jigsaw.w3.org/css-validator/. I get back some errors, but I
don't understand them. I will leave you with the errors and then the
CSS. Thanks in advance.

Line : 24 (Level : 1) You have no background-color with your color :
div.navigationItem a
Line : 29 (Level : 1) You have no color with your background-color :
div.navigationItem a:link
These are warning, not errors. The reason is a visitor may have set a
text color the same as your background, and would not be able to see
your text.

Quote:
div.navigationItem a {
display: block;
font-weight: bold;
text-decoration: none;
text-align: right;
letter-spacing: 1px;
margin: 0px;
color: blue; /* THIS IS LINE 24 */
--> background: white;
border-top: 1px solid black;
}

div.navigationItem a:link{
background: white; /* THIS IS LINE 29 */
--> color: black;
text-decoration: none;
}
The rule is: if you set one, set the other as well.

--
-bts
-Warning: I brake for lawn deer


Reply With Quote
  #3  
Old   
Jim Moe
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-12-2005 , 07:21 PM



eomer wrote:
Quote:
Hi, I trying to validate myy CSS using
http://jigsaw.w3.org/css-validator/. I get back some errors, but I
don't understand them. I will leave you with the errors and then the
CSS. Thanks in advance.

Line : 24 (Level : 1) You have no background-color with your color :
div.navigationItem a
Line : 29 (Level : 1) You have no color with your background-color :
div.navigationItem a:link

I believe those are only warnings.
To avoid certain problems where foreground or background defaults may
have unintended consequences, it is advisable to pair color and background
together. Most of the time it does not matter.
A common place where this is important is in <body>. A foreground color
(for text) is typically specified but the background color is not. Some
people have a non-white background selected (for whatever reason), say
black, that can contrast poorly with the foreground color, which is
usually black. Hard to read.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)


Reply With Quote
  #4  
Old   
Rob Stampfli
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-13-2005 , 12:10 AM



In article <1piv67uh0nev2$.1eh1vecgacg97.dlg (AT) 40tude (DOT) net>,
Beauregard T. Shagnasty <a.nony.mous (AT) example (DOT) invalid> wrote:
Quote:
eomer wrote:

Hi, I trying to validate myy CSS using
http://jigsaw.w3.org/css-validator/. I get back some errors, but I
don't understand them. I will leave you with the errors and then the
CSS. Thanks in advance.

Line : 24 (Level : 1) You have no background-color with your color :
div.navigationItem a
Line : 29 (Level : 1) You have no color with your background-color :
div.navigationItem a:link

These are warning, not errors. The reason is a visitor may have set a
text color the same as your background, and would not be able to see
your text.

div.navigationItem a {
display: block;
font-weight: bold;
text-decoration: none;
text-align: right;
letter-spacing: 1px;
margin: 0px;
color: blue; /* THIS IS LINE 24 */
--> background: white;
border-top: 1px solid black;
}

div.navigationItem a:link{
background: white; /* THIS IS LINE 29 */
--> color: black;
text-decoration: none;
}

The rule is: if you set one, set the other as well.
I don't understand the 2nd warning either: It would seem
he has specified both a color (line 24) and a background
color (line 29), right?

Rob


Reply With Quote
  #5  
Old   
Beauregard T. Shagnasty
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-13-2005 , 08:55 AM



Rob Stampfli wrote:

Quote:
In article <1piv67uh0nev2$.1eh1vecgacg97.dlg (AT) 40tude (DOT) net>,
Beauregard T. Shagnasty <a.nony.mous (AT) example (DOT) invalid> wrote:
eomer wrote:

Hi, I trying to validate myy CSS using
http://jigsaw.w3.org/css-validator/. I get back some errors, but I
don't understand them. I will leave you with the errors and then the
CSS. Thanks in advance.

Line : 24 (Level : 1) You have no background-color with your color :
div.navigationItem a
Line : 29 (Level : 1) You have no color with your background-color :
div.navigationItem a:link

These are warning, not errors. The reason is a visitor may have set a
text color the same as your background, and would not be able to see
your text.

div.navigationItem a {
display: block;
font-weight: bold;
text-decoration: none;
text-align: right;
letter-spacing: 1px;
margin: 0px;
color: blue; /* THIS IS LINE 24 */
--> background: white;
border-top: 1px solid black;
}

div.navigationItem a:link{
background: white; /* THIS IS LINE 29 */
--> color: black;
text-decoration: none;
}

The rule is: if you set one, set the other as well.

I don't understand the 2nd warning either: It would seem
he has specified both a color (line 24) and a background
color (line 29), right?
No. In his example, a color is specified for "div.navigationItem a" and
a background color is specified for "div.navigationItem a:link". You
need to assign both for each selector.

--
-bts
-Warning: I brake for lawn deer


Reply With Quote
  #6  
Old   
Rob Stampfli
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-13-2005 , 03:01 PM



In article <2xfkyylxuv3j$.tio0w47en4s2$.dlg (AT) 40tude (DOT) net>,
Beauregard T. Shagnasty <a.nony.mous (AT) example (DOT) invalid> wrote:
Quote:
Rob Stampfli wrote:
....
div.navigationItem a {
display: block;
font-weight: bold;
text-decoration: none;
text-align: right;
letter-spacing: 1px;
margin: 0px;
color: blue; /* THIS IS LINE 24 */
border-top: 1px solid black;
}

div.navigationItem a:link{
background: white; /* THIS IS LINE 29 */
text-decoration: none;
}

The rule is: if you set one, set the other as well.

I don't understand the 2nd warning either: It would seem
he has specified both a color (line 24) and a background
color (line 29), right?

No. In his example, a color is specified for "div.navigationItem a" and
a background color is specified for "div.navigationItem a:link". You
need to assign both for each selector.
This is a poor example, because the color of a:link *is* typically
set implicitly so its color would generally not be inherited, but
the CSS validator consistently complains, as you say, if you assign
either a color or background-color anywhere without specifying the
other.

But, shouldn't the color and/or background-color be inherited if
one is not explicitly given?

In other words, if you've set the background-color in <body>,
why should you need to restate it explicitly if you later set the
color in, say, a <span>? Why should the validator issue a warning
in such a case?

Rob


Reply With Quote
  #7  
Old   
Darin McGrew
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-13-2005 , 04:08 PM



Rob Stampfli <restamp (AT) hotmail (DOT) com> wrote:
Quote:
But, shouldn't the color and/or background-color be inherited if
one is not explicitly given?
Yes. But from what is it going to be inherited?

Quote:
In other words, if you've set the background-color in <body>,
why should you need to restate it explicitly if you later set the
color in, say, a <span>? Why should the validator issue a warning
in such a case?
The C in CSS is for "Cascading". Rules from other style sheets can cascade
with your rules. As an example, you might specify color and background for
BODY elements, but a user style sheet might specify color and background
for P elements. If you specify only color for SPAN elements, which
background will they be shown against?
--
Darin McGrew, mcgrew (AT) stanfordalumni (DOT) org, http://www.rahul.net/mcgrew/
Web Design Group, darin (AT) htmlhelp (DOT) com, http://www.HTMLHelp.com/

"I'd love to make time, if only I could find the recipe."


Reply With Quote
  #8  
Old   
Rob Stampfli
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-13-2005 , 04:22 PM



In article <dnngo6$r72$1 (AT) blue (DOT) rahul.net>,
Darin McGrew <mcgrew (AT) stanfordalumni (DOT) org> wrote:
Quote:

Rob Stampfli <restamp (AT) hotmail (DOT) com> wrote:
But, shouldn't the color and/or background-color be inherited if
one is not explicitly given?

Yes. But from what is it going to be inherited?

In other words, if you've set the background-color in <body>,
why should you need to restate it explicitly if you later set the
color in, say, a <span>? Why should the validator issue a warning
in such a case?

The C in CSS is for "Cascading". Rules from other style sheets can cascade
with your rules. As an example, you might specify color and background for
BODY elements, but a user style sheet might specify color and background
for P elements. If you specify only color for SPAN elements, which
background will they be shown against?
Granted. But, a user style sheet could just as easily specify a
background image for P elements, yet I don't see the validator
complaining about the lack of an explicit "background-image:"
attribute to undo this on every element where a "color" is
specified. So why pick on "background-color"?

Rob


Reply With Quote
  #9  
Old   
Beauregard T. Shagnasty
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-13-2005 , 04:30 PM



Rob Stampfli wrote:

Quote:
So why pick on "background-color"?
Because it is so frequently abused by newbie authors? :-)

--
-bts
-Warning: I brake for lawn deer


Reply With Quote
  #10  
Old   
Chris Morris
 
Posts: n/a

Default Re: Writing Valid CSS (help) - 12-14-2005 , 04:22 AM



restamp (AT) hotmail (DOT) com (Rob Stampfli) writes:
Quote:
Granted. But, a user style sheet could just as easily specify a
background image for P elements, yet I don't see the validator
complaining about the lack of an explicit "background-image:"
attribute to undo this on every element where a "color" is
specified. So why pick on "background-color"?
Usually better to use "background" rather than "background-color" in
author stylesheets, for precisely that reason. I thought the CSS
checker *did* advise that, but maybe not.

--
Chris


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.