The caption tag in HTML
- 24-07-2022
- Trung Minh
- 0 Comments
The <caption> tag is used to set a title for a table, the <caption> tag must be placed immediately after the <table> tag.
Only one <caption> can be placed per <table> . tag
How to use the <caption> . tag
Example : set caption for savings board
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <table> <caption>Monthly savings</caption> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$50</td> </tr> </table> </body> </html>
Attribute of <caption> . tag
The <caption> tag is supported by all Global Attributes in HTML.