HTML <caption> tagS2C Home   « HTML <caption> tag

Definition

The <caption> tag is used for defining a table caption.

Example


<table>
  <caption>Caption Name</caption>
  <tr>
    <th>Fruit</th>
    <th>Colour</th>
  </tr>
  <tr>
    <td>Banana</td>
    <td>Yellow</td>
  </tr>
  <tr>
    <td>Pea</td>
    <td>Green</td>
  </tr>
</table>
Caption Name
Fruit Colour
Banana Yellow
Pea Green

Attributes

The following attributes can be used with the <caption> tag.


<caption> Specific Attributes
Attribute Value Description Example
There are no required or optional attributes specific to the <caption> tag.
<caption> Global Attributes
Attribute Description Example
Common
classSpecifies a classname for the element allowing you to apply the style of the predefined class to the content.

</caption class="name">Caption Text</caption>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

</caption id="name">Caption Text</caption>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

</caption style="color:red;">Caption Text</caption>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

</caption title="Content info">Caption Text</caption>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

</caption accesskey="a">Caption Text</caption>
tabindexSpecifies a tab order for the element.

</caption tabindex="1">Caption Text</caption>
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
</caption dir="ltr">Caption Text</caption>
<!-- The text will flow from right to left -->
</caption dir="rtl">Caption Text</caption>
langSpecifies a language code for the content of the element.

</caption lang="en">Caption Text</caption>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the contentt.

<!-- Valid values true and false. -->
<!-- Default inherited / browser specific. -->
</caption spellcheck="true">Caption Text</caption> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
</caption translate="no">Caption Text</caption> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
</caption contenteditable="true">Caption Text</caption> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
</caption draggable="true">Caption Text</caption>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

<!-- Valid values an empty string or hidden -->
</caption hidden>Caption Text</caption> 
</caption hidden="hidden">Caption Text</caption> 
<caption> Event Attributes
Attribute Description Example
Document Element
oncopyThe script to be run when the user copies the content of an element.

 <!-- Executes go() function -->
</caption oncopy="go()">Caption Text</caption> 
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
</caption oncut="go()">Caption Text</caption>
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
</caption onpaste="go()">Caption Text</caption>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
</caption ondrag="go()">Caption Text</caption>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
</caption ondragend="go()">Caption Text</caption>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
</caption ondragenter="go()">Caption Text</caption>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
</caption ondragleave="go()">Caption Text</caption>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
</caption ondragover="go()">Caption Text</caption>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
</caption ondragstart="go()">Caption Text</caption>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
</caption ondrop="go()">Caption Text</caption>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
</caption onblur="go()">Caption Text</caption>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
</caption onchange="go()">Caption Text</caption>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
</caption oncontextmenu="go()">Caption Text</caption>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
</caption onfocus="go()">Caption Text</caption>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
</caption oninput="go()">Caption Text</caption>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
</caption oninvalid="go()">Caption Text</caption>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
</caption onreset="go()">Caption Text</caption>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
</caption onselect="go()">Caption Text</caption>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
</caption onsubmit="go()">Caption Text</caption>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
</caption onkeydown="go()">Caption Text</caption>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
</caption onkeypress="go()">Caption Text</caption>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
</caption onkeyup="go()">Caption Text</caption>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
</caption onabort="go()">Caption Text</caption>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
</caption oncanplay="go()">Caption Text</caption>
oncanplaythroughThe script to be run when a file can be played all the way to the end without further need of buffering.

 <!-- Executes go() function -->
</caption oncanplaythrough="go()">Caption Text</caption>
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
</caption oncuechange="go()">Caption Text</caption>
ondurationchangeThe script to be run when the length of the media is changed.

 <!-- Executes go() function -->
</caption ondurationchange="go()">Caption Text</caption>
onemptiedThe script to be run when a media resource element suddenly becomes empty, usually due to an error.

 <!-- Executes go() function -->
</caption onemptied="go()">Caption Text</caption>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
</caption onended="go()">Caption Text</caption>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
</caption onloadeddata="go()">Caption Text</caption>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
</caption onloadedmetadata="go()">Caption Text</caption>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
</caption onloadstart="go()">Caption Text</caption>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
</caption onpause="go()">Caption Text</caption>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
</caption onplay="go()">Caption Text</caption>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
</caption onplaying="go()">Caption Text</caption>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
</caption onprogress="go()">Caption Text</caption>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
</caption onratechange="go()">Caption Text</caption>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
</caption onseeked="go()">Caption Text</caption>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
</caption onseeking="go()">Caption Text</caption>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
</caption onstalled="go()">Caption Text</caption>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
</caption onsuspend="go()">Caption Text</caption>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
</caption ontimeupdate="go()">Caption Text</caption>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
</caption onvolumechange="go()">Caption Text</caption>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
</caption onwaiting="go()">Caption Text</caption>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
</caption onclick="go()">Caption Text</caption>
ondblclickThe script to be run when a mouse is double clicked on an element.

 <!-- Executes go() function -->
</caption ondblclick="go()">Caption Text</caption>
onmousedownThe script to be run when he mouse button is pressed down while the cursor is over an element.

 <!-- Executes go() function -->
</caption onmousedown="go()">Caption Text</caption>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
</caption onmousemove="go()">Caption Text</caption>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
</caption onmouseout="go()">Caption Text</caption>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
</caption onmouseover="go()">Caption Text</caption>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
</caption onmouseup="go()">Caption Text</caption>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
</caption onwheel="go()">Caption Text</caption>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
</caption onscroll="go()">Caption Text</caption> 
Window - NONE