
- Border: It is used to specify a border and its thickness for a table.
- Cellspacing: It is used to specify the distance between adjacent cells in a table.
- Cellpadding: it is used to specify the distance between a cell and cell contents in a table.
- Width: It is used to specify width of a table in pixels or as percentage to screen width.
- Align: It is used to specify the horizontal alignment of a table. Possible horizontal alignment values are “left”, “right” or “center”.
- Valign: It is used to set the vertical alignment of a table as “top”, “bottom” or “middle”.
- Bgcolor: It sets the background color of a table. You can specify color names or hex values for the color.
Example of table with border=1, width=200 and align=center attributes
HTML Coding:
<table border=”1″ width=”200″ align=”center”>
<tr>
<th>Book</th><th>Price($)</th>
</tr>
<tr>
<td>Visual Basic</td><td>75</td>
</tr>
<tr>
<td>C++</td><td>45</td>
</tr>
</table>
Book |
Price($) |
Visual Basic |
75 |
C++ |
45 |
Example of table with border=5, cellpadding=”10″ and cellspacing=”10″
<table border=”5″ cellpadding=”10″ cellspacing=”10″>
<tr>
<th>Book</th><th>Price($)</th>
</tr>
<tr>
<td>Visual Basic</td><td>75</td>
</tr>
<tr>
<td>C++</td><td>45</td>
</tr>
</table>
Book |
Price($) |
Visual Basic |
75 |
C++ |
45 |
Example table with border=”5″ width=”300″ bgcolor=”yellow”
<table border=”5″ width=”300″ bgcolor=”yellow”>
<tr>
<th>Book</th><th>Price($)</th>
</tr>
<tr>
<td>Visual Basic</td><td>75</td>
</tr>
<tr>
<td>C++</td><td>45</td>
</tr>
</table>
Book |
Price($) |
Visual Basic |
75 |
C++ |
45 |