HTMLテーブル
HTMLテーブルは、
| タグを使用して定義されます。テーブルデータは、 | タグを使用して定義されます。 構文以下は構文です- <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> 出力
|
|---|