<tr>
HTML <tr> 標(biāo)簽 實(shí)例 一個(gè)簡(jiǎn)單的 HTML 表格,包含兩列兩行: <table border='1'> <tr> <th>Month</th> <..
HTML <tr> 標(biāo)簽
實(shí)例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <table border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </table> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
瀏覽器支持
所有主流瀏覽器都支持 <tr> 標(biāo)簽。
標(biāo)簽定義及使用說明
<tr> 標(biāo)簽定義 HTML 表格中的行。
一個(gè) <tr> 元素包含一個(gè)或多個(gè) <th> 或<td> 元素。
HTML 4.01 與 HTML5之間的差異
在 HTML 5 中,不支持 <tr> 標(biāo)簽在 HTML 4.01 中的任何屬性。
屬性
屬性 | 值 | 描述 |
---|---|---|
align | right left center justify char | HTML5 不支持。定義表格行的內(nèi)容對(duì)齊方式。 |
bgcolor | rgb(x,x,x) #xxxxxx colorname | HTML5 不支持。HTML 4.01 已廢棄。規(guī)定表格行的背景顏色。 |
char | character | HTML5 不支持。規(guī)定根據(jù)哪個(gè)字符來進(jìn)行文本對(duì)齊。 |
charoff | number | HTML5 不支持。規(guī)定第一個(gè)對(duì)齊字符的偏移量。 |
valign | top middle bottom baseline | HTML5 不支持。規(guī)定表格行中內(nèi)容的垂直對(duì)齊方式。 |
全局屬性
<tr> 標(biāo)簽支持 HTML 的全局屬性。
事件屬性
<tr> 標(biāo)簽支持 HTML 的事件屬性。
嘗試一下 - 實(shí)例
表格中的標(biāo)題
本例演示如何顯示表格標(biāo)題。
實(shí)例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <h4>表格使用水平標(biāo)題:</h4> <table border="1"> <tr> <th>Name</th> <th>Telephone</th> </tr> <tr> <td>Bill Gates</td> <td>555 77 854</td> </tr> </table> <h4>表格使用垂直標(biāo)題:</h4> <table border="1"> <tr> <th>First Name:</th> <td>Bill Gates</td> </tr> <tr> <th>Telephone:</th> <td>555 77 854</td> </tr> </table> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
空單元格
本例演示如何使用 " " 處理沒有內(nèi)容的單元格。
實(shí)例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <table border="1"> <tr> <td>一些文本</td> <td>一些文本</td> </tr> <tr> <td></td> <td>一些文本</td> </tr> </table> <p>如果在上面的空單元格中沒有邊框,你可以插入一個(gè)空格 : </p> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
帶有標(biāo)題的表格
本例演示一個(gè)帶標(biāo)題(caption)的表格。
實(shí)例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <table border="1"> <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>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
表格內(nèi)的標(biāo)簽
本例演示如何在其他的元素內(nèi)顯示元素。
實(shí)例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <table border="1"> <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>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
跨行或跨列的表格單元格
本例演示如何定義跨行或跨列的表格單元格。
實(shí)例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <h4>單元格跨兩格:</h4> <table border="1"> <tr> <th>Name</th> <th colspan="2">Telephone</th> </tr> <tr> <td>Bill Gates</td> <td>555 77 854</td> <td>555 77 855</td> </tr> </table> <h4>單元格跨兩列:</h4> <table border="1"> <tr> <th>First Name:</th> <td>Bill Gates</td> </tr> <tr> <th rowspan="2">Telephone:</th> <td>555 77 854</td> </tr> <tr> <td>555 77 855</td> </tr> </table> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
相關(guān)文章
HTML 教程:HTML 表格
HTML DOM 參考手冊(cè):Tr 對(duì)象