HTML Table은
| 태그를 사용하여 정의됩니다. | 태그를 사용하여 테이블 데이터를 정의합니다. 구문다음은 구문입니다 - <table> <tr> <th>Table Header</th> <th>Table Header</th> </tr> <tr> <td>Table data</td> <td>Table data</td> </tr> <tr> <td>Table data</td> <td>Table data</td> </tr> </table> HTML 테이블 속성
HTML 캡션 요소HTML 캡션 요소를 사용하여 테이블에 캡션을 설정할 수도 있습니다. 구문다음은 구문입니다 - <caption>text</caption> 예시HTML 테이블의 예를 살펴보겠습니다. <!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
text-align: center;
}
table {
margin: 2rem auto;
width: 400px;
}
caption {
color: #fff;
font-size: 1.5rem;
}
</style>
<body>
<h1>HTML Tables</h1>
<table border="2">
<caption>Student Data</caption>
<tr>
<th>Name</th>
<th>Roll No.</th>
</tr>
<tr>
<td>John</td>
<td>031717</td>
</tr>
<tr>
<td>Elon</td>
<td>051717</td>
</tr>
</table>
</body>
</html> 출력
|
|---|
