HTML tables allow you to arrange data like text, images, and links in rows and columns. You use the <table>
tag to start and end a table.
<table>
: Defines the table itself.<tr>
: Used for table rows.<th>
: Used for table headings.<td>
: Used for table cells (data).<caption>
: Used to set caption for table<table>
<captioin>Personal info</caption>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Chandu</td>
<td>18</td>
</tr>
</table>
Rowspan: If you want a table cell to span multiple rows, you can use the rowspan
attribute.
Colspan: If you want a table cell to span multiple columns, you can use the colspan
attribute.
<table border="1">
<tr>
<td colspan="2">Merged columns</td>
</tr>
<tr>
<td>column 1</td>
<td>column 2</td>
</tr>
</table>
<table border="1">
<tr>
<td>row1, column1</td>
<td rowspan="2">Merged rows</td>
<tr>
<tr>
<td>row2, column2</td>
<tr>
</table>