0

Haow can I add colour to a table? does anyone know?

7th Jun 2016, 2:06 PM
Sree Harshan
Sree Harshan - avatar
6 Answers
+ 3
Here's an example of a css styled table: <style> table { border-collapse: collapse; width: 50%; background: #e5f2f2; border: 1px solid #008080; } th, td { padding: 0.5em; text-align: left; border: 1px solid #008080; } th { background: #008080; color: #fff; } tr:nth-child(odd) { background: #b2d8d8; } </style> <table> <thead> <tr> <th>Header</th> <th>Header</th> <th>Header</th> <th>Header</th> </tr> </thead> <tbody> <tr> <td>Item</td> <td>Item</td> <td>Item</td> <td>Item</td> </tr> <tr> <td>Item</td> <td>Item</td> <td>Item</td> <td>Item</td> </tr> <tr> <td>Item</td> <td>Item</td> <td>Item</td> <td>Item</td> </tr> <tr> <td>Item</td> <td>Item</td> <td>Item</td> <td>Item</td> </tr> </tbody> </table>
7th Jun 2016, 11:03 PM
ZinC
ZinC - avatar
0
if u add the color in table heading then use: <td bgcolor="blue">blue</td>
7th Jun 2016, 2:24 PM
kiran
0
when u code the table ...just do <td bgcolor="the color u want">colour </td>
7th Jun 2016, 3:16 PM
Ozii
Ozii - avatar
0
NO! no bgcolor. That's old and deprecated. Use stylesheets.
7th Jun 2016, 7:50 PM
ZinC
ZinC - avatar
0
external css would be table { background-color: #fefefe; border: 1px solid #000; }
11th Jun 2016, 6:22 AM
Matt
0
It is highly recommended to style your document through CSS rules and not through HTML attributes. To put background color to a table you must style the cell directly. For example, if you want to style th and td elements, use the background property through a CSS rule applied to these selectors. Example: th, td { background-color: blue: color: #fff; }
26th Jun 2016, 7:28 PM
Elena Alexie
Elena Alexie - avatar