hi guys, i have this code..to display a table.. but how to add a background color to a table? any help is greatly appreciated.. thanks...

<table cellpadding="15" cellspacing="15">
<tr>
<td>CELL 1</td>
<td>CELL 2</td>
</tr>
<tr>
<td>CELL 3</td>
<td>CELL 4</td>
</tr>
</table>

edit your table to something like <table cellpadding="15" cellspacing="15" bgcolor="red"> OR with(RGB) <table cellpadding="15" cellspacing="15" bgcolor="#FF0000">

That is ancient code. Add a style to the stylesheet instead:

table {background-color: #ff0000;}
table {background-color: #ff0000;}

hi MidiMagic, how to call that code to the table..

i used like this but it doesn't work, how to do it? thanks...:

<style type="text/css">
#table1 {background-color: #ff0000;}
</style>

<table class="table1" cellpadding="15" cellspacing="15">

#table1 - means id=table1
so

edit your html to...
<table id="table1" ...>

if you use

table {background-color: #ff0000;}

you don't need to add class or id to your table, it will change all table background to #ff0000

yes please use a stylesheet that was if you need to use it again you can just declare the class again and dont use "red" or "white" use the proper hash code like "#fffffff"

if you use

table {background-color: #ff0000;}

you don't need to add class or id to your table, it will change all table background to #ff0000

i've tried it but it doesn't work...

Mmmm thats strange,

<!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=utf-8" />
<title>Untitled Document</title>
<style>
	table {
		background: #000000;
	}
</style>
</head>

<body>
<table width="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

Here's my example and its work

Two points:

use:

.stylename for a class

#stylename for an id

Note that class can be used on multiple tags, id can not.

The use of width= in the tag causes some browsers to ignore the style. Put the width and border in the style too.