HTML5 > Structures

Caption in HTML5

How to create the captions for the table in HTML5?


In HTML5 the <caption> tag is used for creating the table captions/title. It represents the title of the table, the <caption> tag should be used once at a time immediately after the <table> tag.

<body>
    <table>
        <caption>This is the caption of the table.</caption>
        <tr>
            <td>1</td>
            <td>2  fdsa f asd f af a df ads  fasd f sad f </td>
        </tr>
        <tr>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </table>
</body>

In the above snippet code we can notice that the <caption> tag is used once at a time immediately after the <table> tag.

Output

Notice that the text inside the <caption> tag is appearing like a caption of the table in the webpage.

 Views: 5002 | Post Order: 68



Write for us






Hosting Recommendations