tr과 td의 구분

박태민·2023년 10월 25일
0

html/css/javascript

목록 보기
1/5

html로 표를 만들 때 tr(table row)과 td(table data)의 방향성이 초기에 헷갈렸었는데 우리가 행렬을 말할 때 '행', '열'의 순서로 말하는 것에 따라 tr이 먼저 나오니까 '행', td가 tr의 하위에 나오니까 '열' 로 인식하면 쉽게 구분할 수 있다.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<table>
   <tr>		   <!-- 1행 -->
    <td>a</td> <!-- 1열 -->
    <td>b</td> <!-- 2열 -->
    <td>c</td> <!-- 3열 -->
   </tr> 
   <tr>		   <!-- 2행 -->
    <td>d</td> <!-- 1열 -->
    <td>e</td> <!-- 2열 -->
    <td>f</td> <!-- 3열 -->
</table>
</body>

위의 코드의 결과는 다음과 같이 나온다

a b c
d e f
profile
30대 비전공으로 개발시작한닷

0개의 댓글