Advertisement
❮ Previous: <canvas> Next: <cite> ❯

<caption>

HTML <caption> (Table Caption) Tag

Example

<table>
<caption>User Name</caption>
<tr>
  <th>First Name</th>
  <th>Last Name</th>
</tr>
<tr>
  <td>John</td>
  <td>Doe</td>
</tr>
</table>

Try this code ❯

Meaning

The <caption> element is used within the table element to define a caption.

Notes:

Version: HTML 3.2, 4, 4.01, 5


Standard Syntax

<caption>...</caption>


Advertisement

Global Attributes

<caption> element also supports the Global Attributes in HTML.


Event Attributes

<caption> element also supports the Event Attributes in HTML.


More Examples

Example

<table>
<caption style="text-align: left">User name</caption>
<tr>
  <th>First Name</th>
  <th>Last Name</th>
</tr>
<tr>
  <td>John</td>
  <td>Doe</td>
</tr>
</table>


<br>
<br>

<table>
<caption style="caption-side: bottom">User name</caption>
<tr>
  <th>First Name</th>
  <th>Last Name</th>
</tr>
<tr>
  <td>John</td>
  <td>Doe</td>
</tr>
</table>

Try this code ❯


By Default CSS Value(s)

Most of the browsers will display the <caption> element with the following by default value(s)

caption {
  display: table-caption;
  text-align: center;
}

Related Tags:

<col>,
<colgroup>,
<table>,
<tbody>,
<td>,
<tfoot>,
<th>,
<thead> and
<tr>

❮ Previous: <canvas> Next: <cite> ❯
Advertisement