<caption> Tag in HTML

The <caption> tag is used to specify a title or a description for a <table> element. It is typically placed directly after the opening <table> tag and before any <thead>, <tbody>, or other table sections.

Key Points on <caption> Tag:

Syntax of <caption> Tag:

Syntax Example

<table>
            <caption>Table Title</caption>
            
        </table>

Example of <caption> Tag in HTML:

This example demonstrates how the <caption> tag is used within a table to provide a title or description.

Code Example


        <table border="1">
            <caption>Employee Information</caption>
            <tr>
                <th>Name</th>
                <th>Position</th>
            </tr>
            <tr>
                <td>John Doe</td>
                <td>Manager</td>
            </tr>
            <tr>
                <td>Jane Smith</td>
                <td>Developer</td>
            </tr>
        </table>
                

Output

Employee Information
Name Position
John Doe Manager
Jane Smith Developer

The <caption> tag is mainly used for giving context to the table, especially for accessibility purposes. It helps screen readers identify the purpose of the table, improving the overall accessibility of the webpage.