HTML <col> 태그
예시
<colgroup> 및 <col> 태그를 사용하여 세 열의 배경색을 설정합니다.
<table>
<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>
</table>
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
태그 는 <colgroup> 요소 <col>
내의 각 열에 대한 열 속성을 지정합니다
.
<col>
태그는 각 행에 대해 각 셀의 스타일을 반복하는 대신 전체 열에 스타일을 적용하는 데 유용합니다 .
브라우저 지원
Element | |||||
---|---|---|---|---|---|
<col> | Yes | Yes | Yes | Yes | Yes |
속성
Attribute | Value | Description |
---|---|---|
span | number | Specifies the number of columns a <col> element should span |
전역 속성
<col>
태그는 HTML의 전역 속성도 지원 합니다 .
이벤트 속성
<col>
태그는 HTML의 이벤트 속성 도 지원합니다 .
더 많은 예
예시
표 열의 텍스트 정렬(CSS 사용):
<table style="width:100%">
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td style="text-align:right">$53</td>
</tr>
<tr>
<td>2489604</td>
<td>My first CSS</td>
<td style="text-align:right">$47</td>
</tr>
</table>
예시
테이블 열의 텍스트 수직 정렬(CSS 사용):
<table style="height:200px">
<tr>
<th>Month</th>
<th
style="vertical-align:bottom">Savings</th>
</tr>
<tr>
<td>January</td>
<td
style="vertical-align:bottom">$100</td>
</tr>
</table>
예시
표 열의 너비 지정(CSS 사용):
<table>
<tr>
<th
style="width:130px">Month</th>
<th
style="width:80px">Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
관련 페이지
HTML DOM 참조: 열 개체
기본 CSS 설정
대부분의 브라우저는 <col>
다음 기본값으로 요소를 표시합니다.
예시
col {
display: table-column;
}