|
Table backgroundYou can user either a color or image as the background of your table. We will now show you how to do it. To add a background color, you would use the code bgcolor="" which means background color. This code is added to the <table> tag so that it works throughout the entire table. You can also use background="url" to add a background image. The example below will use the background color pink:
<table bgcolor="pink" border="1">
You also add a background color to individual cells/rows or columns just by placing the bgcolor="" code in the <tr> or <td> tag. We will now add the color yellow to one or the columns in a pink table.
<table bgcolor="pink" border="1">
<tr bgcolor="yellow">
As you can see, the background of the column changed to yellow. What happens if we want a cell/row to have the background green? Well, we just need to add the bgcolor="" code in the <td> tag. We will try doing that to one of the cells/rows from the above table.
<td bgcolor="green">
If you want to use an image as the background, then you will need to use the background="" code. In the quotation marks, you will write the URL of the image you want to use as the background. Right now, we will try using the demo.gif as the background in a table as an example: <table width="100px" height="100px" background="/demo.gif" border="1">
If you want to use CSS for the background then you can use this code for the background color:
<table style="background:#hex code;">
You will need to place the hex code of the color you want as the background but remember that you will need the # (number sign) before the hex code. If you would like to use a background image, then you can use the following code:
<table style="background:url(file location);">
You will need to place the URL of the image in the parentheses (file location). |