Html Caption tag

In the html <caption> tag is used to creating table caption and it must be after <table> tag. In the <caption> tag must be center and it only one tag in inside of <table>.

Syntax:

<table>
  <caption> ... </caption>
  <tr>
    <td> ... </td>
  </tr>
</table>

Example Code

<table>
  <caption>Caption </caption>
  <tr>
    <th> Heading 1 </th>
    <th> Heading 2 </th>
  </tr>
  <tr>
    <td> Data 1 </td>
    <td> Data 2 </td>
  </tr>
</table>

Out Put:



Caption
Heading 1 Heading 2
Data 1 Data 2

In the above example <Caption> tag has been added to table.





Content