<table>
<tr>
<td>a1</td>
<td>b1</td>
<td>c1</td>
</tr>
<tr>
<td>a2</td>
<td>b2</td>
<td>c2</td>
</tr>
<tr>
<td>a3</td>
<td>b3</td>
<td>c3</td>
</tr>
</table>
如果我們需要讓第一排(a1、a2、a3)背景變黃色,不需要一個一個td去控制,只要利用html的colgroup標籤與col標籤,如下:
<table>
<colgroup>
<col style="background-color:yellow">
<col>
<col>
</colgroup>
<tr>
<td>a1</td>
<td>b1</td>
<td>c1</td>
</tr>
<tr>
<td>a2</td>
<td>b2</td>
<td>c2</td>
</tr>
<tr>
<td>a3</td>
<td>b3</td>
<td>c3</td>
</tr>
</table>
No comments:
Post a Comment