By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

CSS Validation issue

P: n/a
Hi everybody,

Here's a little problem that's been bothering me. I have a stylesheet, in
which I define the looks of a table on my website. Each alternating row
gets a different color, as is usually done on most websites.

This means that each alternating <trgets an extra class="alt" attribute -
no problems so far.

After validating my CSS, however, I found that I still had three errors
left:
* Line : 253 (Level : 1) You have no background-color with your color :
td
* Line : 259 (Level : 1) You have no background-color with your color :
td a
* Line : 264 (Level : 1) You have no background-color with your color :
td a:hover

I'd like to correct these, but as soon as I put in a background-color with
my color, the alternating color that was set by the tr disappears, quite
logically.

How do I fix this?

I can always add the alternate class to the tds instead of the trs, but
that means that the size of my resulting html file will increase a lot
(each tr has a lot of tds).

Thanks in advance,

Ikke
Nov 2 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Thu, 2 Nov 2006 13:51:18 +0000, Ikke wrote
(in article <Xn************************@195.130.132.70>):
Hi everybody,

Here's a little problem that's been bothering me. I have a stylesheet, in
which I define the looks of a table on my website. Each alternating row
gets a different color, as is usually done on most websites.

This means that each alternating <trgets an extra class="alt" attribute -
no problems so far.

After validating my CSS, however, I found that I still had three errors
left:
* Line : 253 (Level : 1) You have no background-color with your color :
td
* Line : 259 (Level : 1) You have no background-color with your color :
td a
* Line : 264 (Level : 1) You have no background-color with your color :
td a:hover

I'd like to correct these, but as soon as I put in a background-color with
my color, the alternating color that was set by the tr disappears, quite
logically.

How do I fix this?

I can always add the alternate class to the tds instead of the trs, but
that means that the size of my resulting html file will increase a lot
(each tr has a lot of tds).

Thanks in advance,
Hi

I like to do this alternating colours for the rows in tables.

I tend to go "odds" and "evens" with my class names for this so below
is the CSS for classes called "nscodd" and "nsceven" in a fairly
standard table. This validates. As you can see "nscodd" is not in fact
doing anything but I keep it there in case I change my mind about how I
want my alternating rows coloured.

tr.nscodd { background-color: inherit; color: inherit; }
tr.nsceven { background-color: #D8D8D8; color: inherit; }


--
Patrick
Brighton, UK

<http://www.patrickjames.me.uk>

Nov 2 '06 #2

P: n/a
patrick j <pa*****@jamesnews.orangehome.co.ukwrote in
news:00*****************************@News.Individu al.Net:

<snip>
Hi

I like to do this alternating colours for the rows in tables.

I tend to go "odds" and "evens" with my class names for this so below
is the CSS for classes called "nscodd" and "nsceven" in a fairly
standard table. This validates. As you can see "nscodd" is not in fact
doing anything but I keep it there in case I change my mind about how
I want my alternating rows coloured.

tr.nscodd { background-color: inherit; color: inherit; }
tr.nsceven { background-color: #D8D8D8; color: inherit; }
Thanks for your suggestion - it has helped me a lot.

My end solution looks like this:
- drop all color declarations for the tds that were already there
- add the declarations in "tr", "tr a" and "tr a:hover"
- add alternate declarations in "tr.alt", "tr.alt a", and "tr.alt a:hover"

Works like a charm!

Best regards,

Ikke
Nov 2 '06 #3

P: n/a
Scripsit Ikke:
>tr.nscodd { background-color: inherit; color: inherit; }
tr.nsceven { background-color: #D8D8D8; color: inherit; }

Thanks for your suggestion - it has helped me a lot.
That's an illusion. IE does not support the value inherit.

So you have silenced the messenger (the CSS checker, or "validator"), but
the problem it tried to tell you about is still there.

Always set background and color together, to explicit values, if you set
either of them for an element.
Works like a charm!
You misspelled "illusion". :-)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Nov 2 '06 #4

P: n/a
"Jukka K. Korpela" <jk******@cs.tut.fiwrote in
news:ST*******************@reader1.news.jippii.net :
Scripsit Ikke:
>>tr.nscodd { background-color: inherit; color: inherit; }
tr.nsceven { background-color: #D8D8D8; color: inherit; }

Thanks for your suggestion - it has helped me a lot.

That's an illusion. IE does not support the value inherit.

So you have silenced the messenger (the CSS checker, or "validator"),
but the problem it tried to tell you about is still there.

Always set background and color together, to explicit values, if you
set either of them for an element.
>Works like a charm!

You misspelled "illusion". :-)
Actually, I took the example posted by Patrick, and altered it to suit my
needs. While doing that, I already explicitly set both colors (mainly
because I'm new to CSS and have never used inherit).

Anyway, thanks for the warning - another lesson learned...

Best regards,

Ikke
Nov 2 '06 #5

P: n/a
On Thu, 2 Nov 2006 23:20:25 +0000, Ikke wrote
(in article <Xn***********************@195.130.132.70>):
Actually, I took the example posted by Patrick, and altered it to suit my
needs. While doing that, I already explicitly set both colors (mainly
because I'm new to CSS and have never used inherit).

Anyway, thanks for the warning - another lesson learned...
I didn't know inherit doesn't work in IE myself :)

I wonder if it works in IE 7?

--
Patrick
Brighton, UK

<http://www.patrickjames.me.uk>

Nov 3 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.