HTML Tables
HTML tables allow web developers to arrange data into rows and columns.
Define an HTML Table
The <table> tag defines an HTML table.
Each table row is defined with a <tr> tag. Each table header is defined with
a <th> tag. Each table data/cell is defined with a <td> tag.
By default, the text in <th> elements are bold and centered.
By default, the text in <td> elements are regular and left-aligned.
HTML Table Tags
Tag Description
<table> It defines a table.
<tr> It defines a row in a table.
<th> It defines a header cell in a table.
<td> It defines a cell in a table.
<caption It defines the table caption.
>
<colgroup It specifies a group of one or more columns in a table for
> formatting.
<col> It is used with <colgroup> element to specify column properties for
each column.
<tbody> It is used to group the body content in a table.
<thead> It is used to group the header content in a table.
<tfooter> It is used to group the footer content in a table.
Program to create a Table.
<html>
<head>
<title>Table</title>
</head>
<body>
<table border="1" width="200" height="200">
<caption>Invoice</caption>
<tr>
<th>Sno</th>
<th>Item</th>
<th>Price</th>
</tr>
<tr>
<td>1</td>
<td>Apple</td>
<td>Rs. 20</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>Rs. 15</td>
</tr>
<tr>
<td>3</td>
<td>Banana</td>
<td>Rs. 3</td>
</tr>
</table>
</body>
</html>
Output :
Invoice
Sno Item Price
1 Apple Rs. 20
2 Mango Rs. 15
3 Banana Rs. 3
[Link]
[Link]