0
Haow can I add colour to a table? does anyone know?
6 ответов
+ 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>
0
if u add the color in table heading then use: <td bgcolor="blue">blue</td>
0
when u code the table ...just do <td bgcolor="the color u want">colour </td>
0
NO! no bgcolor. That's old and deprecated. Use stylesheets.
0
external css would be
table {
background-color: #fefefe;
border: 1px solid #000;
}
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; }