HTML Table
An HTML table is defined with the <table>
tag.
Each table row is defined with the <tr>
tag. A table header is defined with the <th>
tag. By default, table headings are bold and centered. A table data/cell is defined with the <td>
tag.
The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell.
A more complex HTML table may also include <caption>, <col>, <colgroup>, <thead>, <tfoot>, and <tbody> elements.
Attributes
Attribute | Value | Description |
align | left center right | Not supported in HTML5. Specifies the alignment of a table according to surrounding text |
Valign | Top Middle Bottom | Controls the vertical alignment of cell contain it acceptor the value |
bgcolor | rgb(x,x,x) #xxxxxx colorname | Not supported in HTML5. Specifies the background color for a table |
border | 1 0 | Not supported in HTML5. Specifies whether or not the table is being used for layout purposes |
cellpadding | pixels | Not supported in HTML5. Specifies the space between the cell wall and the cell content |
cellspacing | pixels | Not supported in HTML5. Specifies the space between cells |
size | Numeric value | Specifies the Horizontal size of the textbox. |
maxlength | Numeric value | Specifies the Maximum Number of Character that user can enter. |
Cheked | – | Not supported in HTML5. This attribute should be used only for check box and Radio Button from control. It indicates checked status. |
width | pixels % | Not supported in HTML5. Specifies the width of a table |
DISABLE | – | Turn off a from control |
READONLY | – | Prevent the form controls value from being chang. |
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<b>
<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
</b>
</body>
</html>
Output :-
Month | Savings |
January | $100 |
February | $80 |