Tables Background:
- Table element can have background
- We can set background to table in 2 ways.
- We set backgrounds to whole table or only for particular cell depends on requirement.
- We can simple use bgcolor attribute to set any color.
- Image backgrounds can set using ‘background’ attribute.
<!DOCTYPE html>
<html>
<head><title>Table Background</title></head>
<body>
<table border="3" bordercolor="red" bgcolor="yellow">
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
<tr>
<td rowspan="2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
</table>
</body>
</html>
- Here is an example of using background attribute.
- Here we will use an image available in /images directory.
<!DOCTYPE html>
<html>
<head><title>Table Background</title></head>
<body>
<table border="3" bordercolor="green" background="//images//test.png">
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
<tr>
<td rowspan="2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
</table>
</body>
</html>