[thelist] CSS to replace TD bgcolor
Carol Stein
techwatcher at accesswriters.com
Wed Jul 17 11:23:01 CDT 2002
Yes, but ID is fewer characters...
---------------- <snip>
I can have <TD class="aa"> ?
(I have a complex, frequently used page to do. Since it's so frequently
used, it's important that the code be as lean as possible, and I'd like to
be able to save those five characters, especially as this code appears
multiple times.)
</snip> ______________
IF and ONLY IF your table data cell is unique in the page, you can use id (like name) instead of class.
So, if you want every td cell to be a certain color, the general line in CSS
td {background-color: #ffcc99}
(for example) will do it.
If certain TD's, more than one in a page, should be a certain color, you want class. That's written for CSS (for HTML) like this:
in the HTML:
<td class="sp">
and in the stylesheet like this (and you do know you want to link to an external style sheet once for all pages to save download, not put the css between <.style.> tags, right?):
td.sp {background-color: #ffcc99}
But, if your td is so special it only appears once per HTML page, you can do this in the CSS:
td#sp {background-color: #ffcc99}
and THIS in the HTML:
<td id="sp">
saving you another 3 characters (length["class"] - length["id"]).
I'm writing this without checking syntax, since lunch is about to be served, but someone will correct me if I'm wrong.
Cheers --
Carol (techwatcher)
More information about the thelist
mailing list