Create caption for a table in HTML?


Use the <caption> tag to add a caption to a table. You can try to run the following code to include a table caption in HTML −

Example

Here, we have added a table caption “Indian Cricketers” −

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
         border: 1px solid black;
         }
      </style>
   </head>
   <body>
      <h2>Cricketers</h2>
      <table style = "width:100%">
         <caption>Indian Cricketers</caption>
         <th>Name</th>
         <tr>
            <td>Sachin Tendulkar</td>
         </tr>
         <tr>
            <td>Virat Kohli</td>
         </tr>
      </table>
   </body>
</html>

Updated on: 24-Jun-2020

252 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements