Home >Web Front-end >HTML Tutorial >How to use caption tag
Thecaption tag is used to add a title to an HTML table. The caption must appear immediately after the table in the HTML document. It can be positioned intuitively at the bottom of the table using CSS. Let’s take a look. Specific usage of caption tag.
The caption element defines the table title, but only one title can be defined for each table. Usually this title will be centered above the table. (Reference address: HTML table)
Let’s look at a specific example
The code is as follows
<!DOCTYPE How to use caption tag> <How to use caption tag> <head> <title></title> <meta charset="utf-8"> </head> <body> <table border="1" cellspacing="0"> <caption>最喜欢的颜色</caption> <tr> <th>名字</th> <th>喜欢的颜色</th> </tr> <tr> <td>Tom</td> <td>蓝色</td> </tr> <tr> <td>Jerry</td> <td>红色</td> </tr> <tr> <td>Marry</td> <td>粉色</td> </tr> <tr> <td>Cindy</td> <td>黄色</td> </tr> </table> </body> </How to use caption tag>
The effect is as follows: The title is in the middle of the table.
This article ends here. For more exciting content about the front-end, you can pay attention to the relevant column tutorials on the PHP Chinese website! ! !
The above is the detailed content of How to use caption tag. For more information, please follow other related articles on the PHP Chinese website!