轉載自https://www.ggbiji.com/html-col-colgroup.html
<col>標簽是給表格中一個或多個列定義屬性值,而<colgroup>標簽是對表格中的列進行組合,從而實現對表格的格式化。<col>標簽一般會放在<colgroup>標簽中使用,對<colgroup>標簽組合的列分別設置樣式。<colgroup>標簽也可以有樣式屬性,是對組合的列設置相同的樣式,<colgroup>標簽設置的樣式會被<col>標簽設置的樣式覆蓋。
格式:
<colgroup span="跨幾列">
<col 屬性1="屬性值1" 屬性2="屬性值2"....../>
<col 屬性1="屬性值1" 屬性2="屬性值2"....../>
</colgroup>
實例:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>html 中< col>標簽和< colgroup>標簽的區別筆記_PHP筆記</title> </head> <body style="font-size:28px;"> <table width="450" border="1"> <colgroup style="background:red"> </colgroup> <colgroup span="2" style="background:black"> <col style="background:yellow"> <col style="background:red"> </colgroup> <tr><th>學號</th><th>姓名</th><th>成績</th></tr> <tr><td>01</td><td>張三</td><td>50</td></tr> <tr><td>02</td><td>李四</td><td>90</td></tr> </table> </body> </html>
運行結果:

