HTML <caption> (Table Caption) Tag

❮ Previous Reference Next ❯

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>

Meaning

<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>



Browser Support




Status







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>



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 Reference Next ❯