在html中,可以使用caption標(biāo)簽來設(shè)置表格標(biāo)題,該標(biāo)簽的作用就是定義表格的標(biāo)題,語法“<caption>表格標(biāo)題</caption>”;caption標(biāo)簽需要放在“<table></table>”標(biāo)簽對(duì)中。
本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
在html中,可以使用<caption>標(biāo)簽來設(shè)置表格標(biāo)題。
<caption>標(biāo)簽的作用就是定義表格的標(biāo)題。
<caption> 標(biāo)簽需要放在“<table></table>”標(biāo)簽對(duì)中,必須直接放置到 <table> 標(biāo)簽之后。
您只能對(duì)每個(gè)表格定義一個(gè)標(biāo)題。
示例:
<table border="1"> <caption>人物信息</caption> <tr> <th>姓名</th> <th>年齡</th> </tr> <tr> <td>Peter</td> <td>20</td> </tr> <tr> <td>Lois</td> <td>20</td> </tr> </table>
通常這個(gè)標(biāo)題會(huì)被居中于表格之上。然而,CSS 屬性 "text-align" 和 "caption-side" 能用來設(shè)置標(biāo)題的對(duì)齊方式和顯示位置。
<table border="1"> <caption style="caption-side:bottom;">人物信息</caption> <tr> <th>姓名</th> <th>年齡</th> </tr> <tr> <td>Peter</td> <td>20</td> </tr> <tr> <td>Lois</td> <td>20</td> </tr> </table>
推薦教程:《html視頻教程》