SunQuest
           CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 19th, 2003, 10:21 AM
Matthew Doucette Matthew Doucette is offline
matthewdoucette.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Posts: 635 Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level)Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 59 m 37 sec
Reputation Power: 7
Question setting table row color with CSS

I want to set the table row background color (bgcolor) with CSS. What is wrong with my code?

Code:
td.blogtitle { bgcolor: 0000ff; }

...

<td class="blogtitle">
This doesn't work either:

Code:
td.blogtitle { color: 0000ff; }
...

<td class="blogtitle">

Reply With Quote
  #2  
Old August 19th, 2003, 11:07 AM
Ucht's Avatar
Ucht Ucht is offline
This is only a test
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Off the air
Posts: 2,893 Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 20 h 1 m 43 sec
Reputation Power: 147
td.blogtitle { background: 0000ff; }

I don't think bgcolor does anything in css, and color sets font color.

Reply With Quote
  #3  
Old August 19th, 2003, 11:24 AM
Matthew Doucette Matthew Doucette is offline
matthewdoucette.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Posts: 635 Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level)Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 59 m 37 sec
Reputation Power: 7
Quote:
Originally posted by Ucht
td.blogtitle { background: 0000ff; }

I don't think bgcolor does anything in css, and color sets font color.
Worked. Thanks. I knew it was simple. I had no idea it used "background", but I should have still tried it.

Reply With Quote
  #4  
Old August 19th, 2003, 12:13 PM
Akh's Avatar
Akh Akh is offline
|<.+#f@#+.&.|
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2002
Location: norway
Posts: 2,622 Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 2 h 17 m 15 sec
Reputation Power: 548
remember to use the "#" when using hexadecimal notation,

ie. background:#0000ff;

Reply With Quote
  #5  
Old August 19th, 2003, 01:22 PM
Matthew Doucette Matthew Doucette is offline
matthewdoucette.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Posts: 635 Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level)Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 59 m 37 sec
Reputation Power: 7
Quote:
Originally posted by Akh
remember to use the "#" when using hexadecimal notation,

ie. background:#0000ff;
Why is that? I never use #. I also never used quotes when declaring anything in HTML, is that bad too?

Reply With Quote
  #6  
Old August 19th, 2003, 01:45 PM
Akh's Avatar
Akh Akh is offline
|<.+#f@#+.&.|
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2002
Location: norway
Posts: 2,622 Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 2 h 17 m 15 sec
Reputation Power: 548
the use of # is to define that the color attributes you are using are in hexadecimal form
http://www.w3.org/TR/REC-CSS2/syndata.html#color-units

in xhtml you always have to quote the attributes
you are using,
http://www.w3.org/TR/xhtml1/#h-4.4

Reply With Quote
  #7  
Old August 19th, 2003, 02:24 PM
Matthew Doucette Matthew Doucette is offline
matthewdoucette.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Posts: 635 Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level)Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 59 m 37 sec
Reputation Power: 7
If you look at http://www.w3.org/TR/REC-CSS2/syndata.html#color-units you will see that there is not other possible interpretation if you do not use the "#" sign... so most browsers probably default to the proper hexadecimal parsing.

Reply With Quote
  #8  
Old August 19th, 2003, 02:27 PM
Matthew Doucette Matthew Doucette is offline
matthewdoucette.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Posts: 635 Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level)Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 59 m 37 sec
Reputation Power: 7
Check this out about empty elements:

http://www.w3.org/TR/xhtml1/#guidelines

Quote:
C.2. Empty Elements
Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br></br> allowed by XML gives uncertain results in many existing user agents
These guidelines are almost never followed.

Reply With Quote
  #9  
Old August 19th, 2003, 02:35 PM
Akh's Avatar
Akh Akh is offline
|<.+#f@#+.&.|
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2002
Location: norway
Posts: 2,622 Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 2 h 17 m 15 sec
Reputation Power: 548
Quote:
so most browsers probably default to the proper hexadecimal parsing.


but you can't be sure of that so,
therefor one should always specify.

its just the same as setting width:100; to
an element, some browsers might parces that
as 100px, but most wont (as they should)
so you can't always relay on the browsers,

Reply With Quote
  #10  
Old August 19th, 2003, 02:35 PM
fgeller's Avatar
fgeller fgeller is offline
:(){ :|:&};:
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Germany
Posts: 297 fgeller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 4 m 52 sec
Reputation Power: 5
Send a message via ICQ to fgeller
But guidelines are created so that you obey them - and if you want to produce clean code I think you should obey them. Even if nobody else does I see this just as a work that I do to make my code easier to read and understand. I understand it if you don't know that guidelines that you then wouldn't obey them. But as you know them you should use them. And it isn't to hard to add a # or a / - or? At least I try to add them where necessary as long as I remember it
__________________
regards >_<

ws. fgeller.de
em. felix@fgeller.de

Reply With Quote
  #11  
Old August 19th, 2003, 04:36 PM
gupps gupps is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Vancouver
Posts: 7 gupps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
setting the background color of a table row

I was interested in the response to the person who wanted to set the background color of a table row. To my way of thinking however the response only applied to setting the background color of an individual cell.

What is the syntax for setting the color for the whole row without dealing with each cell individually

I tried the following without success

tr.special {background #000080;}


<tr class="special">

Can someone help me out?

Reply With Quote
  #12  
Old August 19th, 2003, 05:38 PM
Ucht's Avatar
Ucht Ucht is offline
This is only a test
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Off the air
Posts: 2,893 Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 20 h 1 m 43 sec
Reputation Power: 147
Make sure you have a colon between background and your color:

{background: #000080;}

Reply With Quote
  #13  
Old August 20th, 2003, 10:16 AM
Matthew Doucette Matthew Doucette is offline
matthewdoucette.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Posts: 635 Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level)Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 59 m 37 sec
Reputation Power: 7
Re: setting the background color of a table row

Quote:
Originally posted by gupps
I was interested in the response to the person who wanted to set the background color of a table row. To my way of thinking however the response only applied to setting the background color of an individual cell.

What is the syntax for setting the color for the whole row without dealing with each cell individually

I tried the following without success

tr.special {background #000080;}


<tr class="special">

Can someone help me out?
Good point. You can not see it from my code, but in my table my row only had one cell so I decided to change just the cell (or just the "td"). Just use the code that works and replace "td" with "tr" like Ucht said.

Reply With Quote
  #14  
Old August 20th, 2003, 10:20 AM
Matthew Doucette Matthew Doucette is offline
matthewdoucette.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Posts: 635 Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level)Matthew Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 59 m 37 sec
Reputation Power: 7
Akh and fgeller, I agree. I am going to go add "#" to all my colors and start quoting variable initializations. It does make sense to stick with what you know is proper.

Reply With Quote
  #15  
Old August 20th, 2003, 02:57 PM
gupps gupps is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Vancouver
Posts: 7 gupps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: Re: setting the background color of a table row

Quote:
Originally posted by Doucette
Good point. You can not see it from my code, but in my table my row only had one cell so I decided to change just the cell (or just the "td"). Just use the code that works and replace "td" with "tr" like Ucht said.


Thanks for the reply. However I still couldnt get it to work so I decided to just use just straight html <tr bgcolor="#000080">

Reply With Quote