...

View Full Version : Put background color....



alaios
12-11-2005, 09:17 PM
Hi do u know how to add some background color to the cells of a table?

gsnedders
12-11-2005, 10:32 PM
th, td {
background-color: #ff0;
}

Like so?

thesmart1
12-11-2005, 11:38 PM
Code:


<table>
<tr>
<td bgcolor="#ffffff">
This is the table cell. It has a background color of white (ffffff).
</td>
</tr>
</table>


Put any property tags (like cellspacing, cellpadding, width, or border) in the <table> tag. For the background color, all you need to do is include a bgcolor tag in the <td> tag as shown above.

mark87
12-11-2005, 11:41 PM
thesmart1 - if we were in the 1990's I'd agree, but bgcolor is not valid anymore...

gsnedders
12-12-2005, 12:30 AM
Code:


<table>
<tr>
<td bgcolor="#ffffff">
This is the table cell. It has a background color of white (ffffff).
</td>
</tr>
</table>


Put any property tags (like cellspacing, cellpadding, width, or border) in the <table> tag. For the background color, all you need to do is include a bgcolor tag in the <td> tag as shown above.
bgcolor tag? That never existed.

thesmart1
12-12-2005, 01:16 AM
bgcolor exists, try it! I use it all the time. What's wrong with that?

_Aerospace_Eng_
12-12-2005, 01:21 AM
bgcolor is still valid just deprecated and yes it does exist. Try validating this.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

</head>

<body>
<table>
<tr>
<td bgcolor="#ffffff">
This is the table cell. It has a background color of white (ffffff).
</td>
</tr>
</table>
</body>
</html>
But because of CSS styling should be taken care of by CSS not the html. The whole point of CSS is to seperate style and structure.

Bill Posters
12-12-2005, 10:01 AM
bgcolor tag? That never existed.

bgcolor exists, try it! I use it all the time. What's wrong with that?

Error404 was trying to subtly point out that bgcolor is not a tag, it's an attribute.

With all respect, having seen a couple of your recent posts, it seems that your technical advice is some years past its 'best by' date.
However, now that you're joined a decent web development forum, you'll have the opportunity to see and learn newer, more modern techniques that will help improve your knowledge of modern web development and bring your skills up to date. :)


(Believe it or not, this post isn't meant to be patronising.)

Elgyn
12-12-2005, 04:03 PM
so just for simple background color what do you use instead of body bgcolor=""

mark87
12-12-2005, 04:12 PM
so just for simple background color what do you use instead of body bgcolor=""

body { background: #F00 }

Please read up on CSS !

Elgyn
12-12-2005, 04:15 PM
but if they do the same thing, what does it matter

mark87
12-12-2005, 04:22 PM
You are using tags and attributes which are very outdated.

These days you should be seperating style and layout from content.

An example of why you should be using CSS - http://www.csszengarden.com/

Learn CSS - http://www.w3schools.com/css/default.asp

Bill Posters
12-12-2005, 05:06 PM
but if they do the same thing, what does it matter

It's probably worthwhile for you to read this…
A List Apart (Feb '01): From Table Hacks to CSS Layout: A Web Designer’s Journey (http://www.alistapart.com/articles/journey/)



Perhaps it's not too late for me to work up the whywebstandards (http://www.whywebstandards.com/) page after all. ;)

gsnedders
12-12-2005, 05:06 PM
but if they do the same thing, what does it matter
bgcolor does not exist under HTML 4.01 Strict, XHTML 1.0 Strict or XHTML 1.1



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum