HTML 開發(fā)手冊
/ <colgroup>
<colgroup>
HTML <colgroup> 標簽 實例 <colgroup> 和 <col> 標簽為表格中的三個列設置了背景色: <table border='1'> <colgroup> ..
HTML <colgroup> 標簽
實例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <table border="1"> <colgroup> <col span="2" style="background-color:red"> <col style="background-color:yellow"> </colgroup> <tr> <th>ISBN</th> <th>Title</th> <th>Price</th> </tr> <tr> <td>3476896</td> <td>My first HTML</td> <td>$53</td> </tr> <tr> <td>5869207</td> <td>My first CSS</td> <td>$49</td> </tr> </table> </body> </html>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
瀏覽器支持
所有主流瀏覽器都支持 <colgroup> 標簽。
標簽定義及使用說明
<colgroup> 標簽用于對表格中的列進行組合,以便對其進行格式化。
通過使用 <colgroup> 標簽,可以向整個列應用樣式,而不需要重復為每個單元格或每一行設置樣式。
注釋:只能在 <table> 元素之內(nèi),在任何一個 <caption> 元素之后,在任何一個 <thead>、<tbody>、<tfoot>、<tr> 元素之前使用 <colgroup> 標簽。
提示:如果想對 <colgroup> 中的某列定義不同的屬性,請在 <colgroup> 標簽內(nèi)使用 <col> 標簽。
HTML 4.01 與 HTML5之間的差異
HTML5 中不再支持 HTML 4.01 中的大部分屬性。
屬性
屬性 | 值 | 描述 |
---|---|---|
align | left right center justify char | HTML5 不支持。規(guī)定在列組合中內(nèi)容的水平對齊方式。 |
char | character | HTML5 不支持。規(guī)定根據(jù)哪個字符來對齊列組中的內(nèi)容。 |
charoff | number | HTML5 不支持。規(guī)定第一個對齊字符的偏移量。 |
span | number | 規(guī)定列組應該橫跨的列數(shù)。 |
valign | top middle bottom baseline | HTML5 不支持。定義在列組合中內(nèi)容的垂直對齊方式。 |
width | pixels % relative_length | HTML5 不支持。規(guī)定列組合的寬度。 |
全局屬性
<colgroup> 標簽支持 HTML 的全局屬性。
事件屬性
<colgroup> 標簽支持 HTML 的事件屬性。