The HTML <caption> tag is used for creating a caption for a table. There could be only one caption per table.
<!DOCTYPE html> <html> <head> <title>HTML caption Tag</title> </head> <body> <h2>Cricketers List</h2> <table width = "100%"> <caption>Indian Cricketers</caption> <th>Name</th> <tr> <td>Sachin Tendulkar</td> </tr> <tr> <td>M S Dhoni</td> </tr> <tr> <td>Suresh Raina</td> </tr> <tr> <td>Virat Kohli</td> </tr> </table> </body> </html>
This will produce the following result −
This tag supports all the global attributes described in HTML Attribute Reference
This tag supports all the event attributes described in HTML Events Reference
Chrome | Firefox | IE | Opera | Safari | Android |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |