[HTML기초] 5. 테이블 요소 의미적 작성

INDEX

  1. 요소
  2. caption요소
  3. colgroup요소
  4. thead, tbody, tfoot요소
  5. thead
  6. tbody
  7. tfoot
  8. scope속성

요소

caption요소

colgroup요소

thead, tbody, tfoot요소

thead

<table>
    <!-- caption과 colgroup 생략 -->
    <thead>
        <tr>
            <th>이름</th>
            <th>나이</th>
            <th>성별</th>
            <th>100M 달리기</th>
            <th>윗몸 일으키기</th>
        </tr>
    </thead>
    <!-- 이하 생략 -->
</table>

tbody

<table>
    <!-- caption, colgroup, thead 생략 -->
    <tbody> <!-- 남/여를 tbody로 구분하여 그룹핑 -->
        <tr>
            <td>홍길동</td>
            <td>22세</td>
            <td>남</td>
            <td>15.25</td>
            <td>29</td>
        </tr>
    </tbody>
    <tbody>
        <tr>
            <td>황진이</td>
            <td>20세</td>
            <td>여</td>
            <td>16.12</td>
            <td>41</td>
        </tr>
    </tbody>
</table>

tfoot

<table>
    <!-- tbody까지 생략 -->
    <tfoot>
        <tr>
            <td colspan="3">참가자 평균</td>
            <td>15.7</td>
            <td>35</td>
        </tr>
    </tfoot>
</table>

image

scope속성

<tr>
    <th scope="row">이름</th>
    <td>홍길동</td>
</tr>

image