HTML <caption>
Tag
Topic: HTML5 Tags ReferencePrev|Next
Description
The <caption>
tag defines the title of a table. The caption text should describe the nature of the table. The caption
tag only permitted immediately after the <table>
start tag. A <table>
element may only contain one <caption>
element.
The following table summarizes the usages context and the version history of this tag.
Placement: | Inline |
---|---|
Content: | Inline and text |
Start/End Tag: | Start tag: required, End tag: required |
Version: | HTML 3.2, 4, 4.01, 5 |
Syntax
The basic syntax of the <caption>
tag is given with:
The example below shows the <caption>
tag in action.
<table>
<caption>User Details</caption>
<thead>
<tr>
<th>No.</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John Carter</td>
<td>[email protected]</td>
</tr>
<tr>
<td>2</td>
<td>Peter Parker</td>
<td>[email protected]</td>
</tr>
<tr>
<td>3</td>
<td>John Rambo</td>
<td>[email protected]</td>
</tr>
</tbody>
</table>
Tag-Specific Attributes
The following table shows the attributes that are specific to the <caption>
tag.
Attribute | Value | Description |
---|---|---|
align |
top |
Obsolete Specifies the position of the caption with respect to the table. |
Global Attributes
Like all other HTML tags, the <caption>
tag supports the global attributes in HTML5.
Event Attributes
The <caption>
tag also supports the event attributes in HTML5.
Browser Compatibility
The <caption>
tag is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: HTML Tables.
Related tag: <table>
.