How do I colour the border on a HTML table?

  • Thread starter Thread starter Sandi
  • Start date Start date
S

Sandi

Guest
This is my table, my manual says to add bordercolor="" but when I add it to the table tag it won't validate.

<table width="80%" border="5" bgcolor="#CCFFFF" cellspacing="2" cellpadding="2" align="center">

<tr>
<th colspan="5" align="center">This is the table heading</th>
</tr>

<tr align="center">
<td bgcolor="blue">data</td><td>data</td><td>data</td>
</tr>

<tr align="center">
<td>data</td><td>data</td><td>data</td>
</tr>

<tr align="center">
<td>data</td><td>data</td><td>data</td>
</tr>
</table>

Many thanks.
 
You should consider using CSS to do this, but to do it with html, you can use the tags:

BORDERCOLOR=""
BORDERCOLORLIGHT=""
BORDERCOLORDARK=""

Inserting a blue border would look like this:

<table width="80%" border="5" bgcolor="#CCFFFF" cellspacing="2" cellpadding="2" align="center" BORDERCOLOR="#0000FF"
BORDERCOLORLIGHT="#33CCFF" BORDERCOLORDARK="#0000CC">

<tr>
<th colspan="5" align="center">This is the table heading</th>
</tr>

<tr align="center">
<td bgcolor="blue">data</td><td>data</td><td...
</tr>

<tr align="center">
<td>data</td><td>data</td><td>data</td...
</tr>

<tr align="center">
<td>data</td><td>data</td><td>data</td...
</tr>
</table>

Be careful with bordercolour though, as different browsers render it very differently, see this webpage: http://www.htmlcodetutorial.com/tables/index_famsupp_149.html
 
bordercolor="" is right, it does work

<table width="80%" border="5" bordercolor="red" bgcolor="#CCFFFF" cellspacing="2" cellpadding="2" align="center">

<tr>
<th colspan="5" align="center">This is the table heading</th>
</tr>

<tr align="center">
<td bgcolor="blue">data</td><td>data</td><td...
</tr>

<tr align="center">
<td>data</td><td>data</td><td>data</td...
</tr>

<tr align="center">
<td>data</td><td>data</td><td>data</td...
</tr>
</table>

If you put the value in the tabe tag it will be the outer border of the 'table' that is red, if you want each one of the td's red, you will have to put it in each td tag.

If it still doesnt work for some reason, try style="border-color:red;"


Good luck, hope this helped
 
Back
Top