The HTML tag table is used to create a structured grid of rows and columns. It is one of the most commonly used tags in HTML for displaying data in a tabular format. Tables are used to organize and present data in a clear and concise manner. They are used in a variety of applications, including web pages, spreadsheets, and databases.
Brief Explanation of HTML Tag: Table
The table tag is used to create a table in HTML. The table is made up of rows and columns, which are defined using the tr (table row) and td (table data) tags, respectively. The th (table header) tag is used to define the header row of the table. The caption tag is used to add a caption to the table.
The table tag has several attributes that can be used to customize the appearance and behavior of the table. The border attribute is used to add a border to the table. The cellpadding attribute is used to add padding to the cells of the table. The cellspacing attribute is used to add spacing between the cells of the table. The width attribute is used to set the width of the table.
Code Examples in HTML Tags
Here are some examples of how to use the table tag in HTML:
Example 1: Basic Table
| First Name |
Last Name |
Age |
| John |
Doe |
30 |
| Jane |
Doe |
25 |
Example 2: Table with Border and Padding
| First Name |
Last Name |
Age |
| John |
Doe |
30 |
| Jane |
Doe |
25 |
Example 3: Table with Caption
Employee Information
| First Name |
Last Name |
Age |
| John |
Doe |
30 |
| Jane |
Doe |
25 |
Example 4: Table with Column Span
| Name |
Contact Information |
| John Doe |
john@example.com |
555-1234 |
| Jane Doe |
jane@example.com |
555-5678 |
Example 5: Table with Row Span
| Name |
Contact Information |
| John Doe |
john@example.com |
| 555-1234 |
| Jane Doe |
jane@example.com |
References