BGCOLOR is a standard attribute specifying the background color of a table. The value may be a named color such as "white" or a color specifying a hexidecimal value in the format of RRGGBB. When using hexidecimal color values the octothorp (pound sign) and the value are enclosed in quotes, for example "#3152A5". If you omit the octothorp or one of the quotation marks you will see very strange results. You may refer to the hexidecimal color reference to find hexidecimal color values. When using a named color for a value the colorname is enclosed in quotes. Do not use spaces in the colorname.
The <TABLE> element is not the only element of a table which uses BGCOLOR. The table row element <TR>, the table heading element <TH>, and the table data element <TD> all use BGCOLOR. If each of the table elements were each coded with a different color all at the same time the row element would take precedence over the table element background color and the table cell elements (<TH> and <TD>) would take precedence over the coding of the table row background color.
The following table demonstrates the use of BGCOLOR.
Here is the code:
<TABLE WIDTH="345" BORDER="3" BGCOLOR="white"
The BGCOLOR <TABLE> attribute is deprecated by the HTML 4 specification, to be supplanted by the background-color attribute of a style sheet.
BORDER is an attribute of the table element which specifies how wide a table border shall be. BORDER="0" specifies no border at all. The default value for the BORDER attribute is 1, so if you code BORDER and do not specify a value, the border will be one pixel wide.
When I used MSIE 5.0.x, and made the first table below, I did not even specify a BORDER
when I made the table. As you can see, Internet Explorer 5 will omit a border if BORDER is not mentioned when coding the table element. It is better, however, to go ahead and
code BORDER="0" for those who have not yet downloaded one of the new free browsers. (The links to these free download sites are back at the bottom of the previous lesson.)
You will have to play with the BORDER values yourself to find the border width you like best for each individual table project. Once you have made a few tables you will find that you will start having favorite values for table attributes.
You may also read about a related attribute: FRAME. The FRAME attribute of the TABLE element allows you to make tables with partial borders.