Attributes to Use with the <table> Tag
| Attribute | Purpose and Syntax | Values |
| bgcolor | Defines the background color of the table <table bgcolor="blue"> |
16 preset colors or hexadecimal colors |
| border | Defines the line weight of the border <table border="1"> If border is not specified, the table will not have a border. |
a number |
| bordercolor | Defines the color of the border <table bordercolor="red"> |
16 preset colors or hexadecimal colors |
| cellpadding | Defines the vertical spacing within the cells <table cellpadding="2"> |
the number of pixels |
| cellspacing | Defines the spacing between cells <table cellspacing="1"> |
the number of pixels |
| height | Defines the height of the table <table height="200"> |
the number of pixels or a percentage of the full window size, e.g., "30%" |
| width | Defines the width of the table <table width="200"> |
the number of pixels or a percentage of the full window size, e.g., "30%" |
Attributes to Use with the <tr> Tag
| Attribute | Purpose and Syntax | Values |
| align | Defines the horizontal alignment of the text within the table row <tr align="center"> |
left, right, center |
| bgcolor | Defines the background color of the table row <tr bgcolor="blue"> |
16 preset colors or hexadecimal colors |
Attributes to Use with the <td> and <th> Tags
| Attribute | Purpose and Syntax | Values |
| align | Defines the horizontal alignment of the text within the table cell <td align="center"> The <td> tag alignment takes precedence over the <tr> tag alignment. |
left, right, center |
| bgcolor | Defines the background color of the table cell <td bgcolor="blue"> |
16 preset colors or hexadecimal colors |
| colspan | Instructs the browser to stretch the cell across a specified number of columns <td colspan="3"> |
the number of columns |
| height | Defines the height of the cell <td height="200"> |
the number of pixels or a percentage of the table size, e.g., "30%" |
| nowrap | Instructs the browser not to wrap the text within the table cell <td nowrap> |
|
| rowspan | Instructs the browser to stretch the cell over a specified number of rows <td rowspan="2"> |
the number of rows |
| valign | Defines the vertical alignment of the text within the table cell <td valign="top"> |
top, middle, bottom |
| width | Defines the width of the table cell <td width="200"> or <td width="50%"> |
the number of pixels or a percentage of the table |
Attributes to Use with the <caption> Tag
| Attribute | Purpose and Syntax | Values |
| align | Defines the position of the caption text <caption align="bottom">Caption Text</caption> |
top, bottom |
Example of Table Attributes:
|
<table width="200" border="1"> <caption align="bottom">Table Caption</caption> <tr align="center"> <th colspan="2">Table Heading</th> </tr> <tr align="left"> <td width="50%">First Item</td> <td width="50%">Second Item</td> </tr> </table> |
|
|||||