You are here: Reference > JavaScript > client-side > HTML DOM > properties > caption (table)

caption property (table)

Browser support:
Returns the caption element of the current table object.

Syntax:

object.caption;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

The caption element of the table object or null if it is not defined.
Default: null.

Example HTML code 1:

This example illustrates the use of the caption property:
<head>
    <script type="text/javascript">
        function GetCaption () {
            var table = document.getElementById ("myTable");
            alert (table.caption.innerHTML)
        }
    </script>
</head>
<body>
    <table id="myTable">
        <caption>The contents of the caption</caption>
        <tr>
            <td>First cell in the table</td>
        </tr>
    </table>
    <button onclick="GetCaption ();">Get the contents of the caption!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content