html5里邊caption的意思是“表格標(biāo)題”,caption標(biāo)簽用于給表格元素添加標(biāo)題,語法為“<caption>表格標(biāo)題</caption>”;caption標(biāo)簽必須直接放置到table標(biāo)簽之后,且每個(gè)表格只能定義一個(gè)標(biāo)題。
本教程操作環(huán)境:windows10系統(tǒng)、HTML5版、Dell G3電腦。
html5里邊caption是什么意思
<caption> 標(biāo)簽定義表格的標(biāo)題。<caption> 標(biāo)簽必須直接放置到 <table> 標(biāo)簽之后。
您只能對每個(gè)表格定義一個(gè)標(biāo)題。通常標(biāo)題會(huì)居中顯示在表格上方。
提示:通常這個(gè)標(biāo)題會(huì)被居中于表格之上。然而,CSS 屬性 "text-align" 和 "caption-side" 能用來設(shè)置標(biāo)題的對齊方式和顯示位置。
語法如下:
<table><caption>表格標(biāo)題</caption></table>
示例如下:
<html> <head> <meta charset="utf-8"> <title>菜鳥教程(runoob.com)</title> </head> <body> <table border="1"> <caption>表格標(biāo)題</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>
輸出結(jié)果:
推薦教程:《html視頻教程》