HTML Tables : – An HTML Table is an arrangement of data in rows and columns in tabular format. Tables are useful for various tasks, such as presenting text information and numerical data. A table is a useful tool for quickly and easily finding connections between different types of data.
<html> <head> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } </style> </head> <body> <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> </body> </html>
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. |
<table border="1" > <tr> <th>Name</th> <th>Age</th> <th>Country</th> </tr> <tr> <td>Harry Depp</td> <td>28</td> <td>Britain</td> </tr> <tr> <td>John Smith</td> <td>35</td> <td>USA</td> </tr> <tr> <td>Ram Krishna</td> <td>19</td> <td>Nepal</td> </tr> </table>
- HTML <table> Tag: This tag is used to create the table that wrap the rows and columns within it.
- HTML <tr> Tag: Stands for “table row” and is used to create a row within the table.
- HTML <td> Tag: Represents “table data” and is used to create standard cells within a row.
- HTML <th> Tag: Represents “table header” and is used to create header cells within a row.