HTML Tags

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:

HTML / XHTML: <caption> ... </caption>

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
bottom
left
right
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.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 4+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Tables.

Related tag: <table>.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties