What is table in HTML?
- HTML Tables are used to represent the data in tabular form on the webpage.
- HTML Tables are collections of rows or columns.
- Tables are created using <table> tag.
Table Tags used in HTML
1). Table
<table> tag is used to create a table in the HTML.
<table> </table>
2). Table Header
<thead> tag is used to create the header section of a table.
<thead> </thead>
3). Table Body
The <tbody> tag is used to defines the body of the table.
<tbody> </tbody>
4). Table Footer
<tfoot> is used to create the footer for the table. This tag is placed at the bottom of the table.
<tfoot> </tfoot>
5). Table Head
<th> is used to define the header of table columns.
<th> </th>
6). Table Row
<tr> tag is used to create a table row.
<tr> </tr>
7). Table Column
<td> is used to create table data cell or columns in the table. It basically contains the table data.
<td> </td>
Table Attributes in HTML
1). border
This attribute is used to set the border on the table.
<table border="1"> </table>
2). colspan
This attribute specifies the number of columns a cell should span.
<td colspan="2"> Frontend Developer</td>
3). rowspan
This attribute specifies the number of rows a cell should span
<td rowspan="2"> Raju Web Dev </td>
Code Described in the video
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Tables in HTML </title>
</head>
<body>
<table border="1">
<tr>
<td> Sr. No. </td>
<td> Name </td>
<td> Roll No. </td>
<td> Role </td>
</tr>
<tr>
<td> 1 </td>
<td> Raju </td>
<td> 4 </td>
<td rowspan="2"> Frontend Developer </td>
</tr>
<tr>
<td> 2 </td>
<td> Rehana </td>
<td> 6 </td>
</tr>
</table>
</body>
</html>