Table part 4

The align and bgcolor Attributes



To change your table's position, use the align attribute inside your table tag:<table align="center">
Now let's specify a background color of red for a table cell. To do that, just use the bgcolor attribute.
<table border="2">
<tr>
<td bgcolor="red">Red</td>
<td>Blue</td>
<td>Green</td>
</tr>
<tr>
<td>Yellow</td>
<td colspan="2">Orange</td>
</tr>
</table>
Try It Yourself

Result:
In the case of styling elements, CSS is more effective than HTML. Try our free "Learn CSS" course to learn more about CSS and styles.

Comments