Web/HTML
html) table, colspan, rowspan
surhommejk
2018. 4. 25. 14:14
colspan
<table>
<tr>
<td>a</td>
<td>b</td>
</tr>
<tr>
<td colspan="2">c</td>
</tr>
</table>
colspan 예시
rowspan
<table>
<tr>
<td rowspan="3">a</td>
<td>b</td>
</tr>
<tr>
<td>c</td>
</tr>
<tr>
<td>d</td>
</tr>
</table>
rowspan 예시
출처: http://webberstudy.com/html-css/html-2/table-basic-structure/
thead, tbody, tfoot의 존재 이유
thead, tbody, tfoot이 없어도 원하는 표를 잘 만들 수 있다. 그렇다면 왜 이 세 가지 태그들이 존재하는 것일까? 몰라서 okky에 질문을 올렸다. 답변으로는 크게 두 가지 의견이 나왔는데 나중에 javascript로 제어하고 싶을때 이를 특정하기 위해서 파트별로 태그로 구분해 두는 것이라는 의견과 시맨틱 웹 관점에서 구조적인 html 일 수록 검색에서 더 잘 걸리기 때문이라는 답변이 있었다.
(참고 : https://okky.kr/article/460602)
따라서 table을 사용할 일이 있으면 꼭 thead와 tbody정도는 무조건 넣는 습관을 들이도록 하자