The HTML <caption>
tag is used to add a caption to a table. The caption is a short description or title that describes the content of the table. The caption is usually placed at the top of the table and is used to provide context for the data in the table.
The <caption>
tag is a container tag that is used to define a caption for a table. The caption is used to provide a brief description of the table and its contents. The caption is usually placed at the top of the table and is used to provide context for the data in the table.
The <caption>
tag is a child element of the <table>
tag and must be placed inside the <table>
element. The <caption>
tag can only be used once per table and should be used to provide a concise and descriptive summary of the table.
Example 1: Basic usage of the <caption>
tag
<table>
<caption>List of Employees</caption>
<tr>
<th>Name</th>
<th>Age</th>
<th>Salary</th>
</tr>
<tr>
<td>John Doe</td>
<td>30</td>
<td>$50,000</td>
</tr>
<tr>
<td>Jane Smith</td>
<td>25</td>
<td>$40,000</td>
</tr>
</table>
Example 2: Using the <caption>
tag with styling
<table style="border: 1px solid black;">
<caption style="font-weight: bold; font-size: 1.2em;">List of Employees</caption>
<tr>
<th>Name</th>
<th>Age</th>
<th>Salary</th>
</tr>
<tr>
<td>John Doe</td>
<td>30</td>
<td>$50,000</td>
</tr>
<tr>
<td>Jane Smith</td>
<td>25</td>
<td>$40,000</td>
</tr>
</table>