Table
A table organizes data into rows and columns.
In HTML, you can create tables on a web page using the <table> tag.
Basic Structure
The main tags for creating a table are as follows:
-
<table>: Creates a table element -
<tr>: Defines a row in a table. It stands for "table row." -
<td>: Defines a data cell. It stands for "table data." -
<th>: Defines a header cell. It is usually displayed in bold.
Example Usage
Below is a simple table example.
<table border="1"> <tr> <th>Name</th> <th>Age</th> <th>Occupation</th> </tr> <tr> <td>John</td> <td>25</td> <td>Developer</td> </tr> <tr> <td>Jane</td> <td>28</td> <td>Designer</td> </tr> </table>
This example creates a 3x3 table where the first row consists of header cells and the subsequent rows contain data cells.
Additional Table Tags
There are other tags available for more sophisticated table structures.
-
<thead>: Groups the header content in a table -
<tbody>: Groups the body content in a table -
<tfoot>: Groups the footer content in a table
Which tag defines a row in an HTML table?
<table>
<th>
<tr>
<td>
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help