HTML table advanced features and accessibility
- HTML table์ ์ถ๊ฐ ์์ฑ ๋ฐ ์ ๊ทผ์ฑ
table์ <caption>
์ถ๊ฐํ๊ธฐ
<table>
์์ ์์<caption>
์์๋ฅผ ์ ์ํ์ฌ table์ ๋ํ ์ค๋ช ์ ์ง์ ํ ์ ์๋ค.<caption>
์์๋ ์ฌ๋<table>
ํ๊ทธ ๋ฐ๋ก ๋ค์ ์์นํ๋ค.
<table>
<caption>Dinosaurs in the Jurassic period</caption>
...
</table>
- table์ ๋ํ ์ค๋ช ์ ์ ๊ณตํด์ฃผ๊ธฐ๋ ํ์ง๋ง ์๊ฐ์ฅ์ ์ธ ์ฌ์ฉ์๋ค์๊ฒ ๋งค์ฐ ์ ์ฉํ๋ค.
→ ์คํฌ๋ฆฐ ๋ฆฌ๋๊ฐ caption
์ ์ฝ์ด table์ ๋ํ ๋ด์ฉ์ ์ป๋๋ค.
table ์์์ summary ์์ฑ๋ ์ฌ์ฉํ ์ ์์ง๋ง HTML5์์ ๋ ์ด์ ์ฌ์ฉ๋์ง ์์ผ๋ฏ๋ก์์๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข๋ค.
Active learning: Adding a caption
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>School timetable</title>
<style>
html {
font-family: sans-serif;
}
table {
border-collapse: collapse;
border: 2px solid rgb(200,200,200);
letter-spacing: 1px;
font-size: 0.8rem;
}
td, th {
border: 1px solid rgb(190,190,190);
padding: 10px 20px;
}
td {
text-align: center;
}
caption {
padding: 10px;
}
</style>
</head>
<body>
<h1>School timetable</h1>
<table>
<caption>This is a school timetable</caption>
<colgroup>
<col span="2">
<col style="background-color:#97DB9A;">
<col style="width: 42px;">
<col style="background-color:#97DB9A;">
<col style="background-color:#DCC48E; border:4px solid #C1437A;">
<col style="width: 42px;" sapn="2">
</colgroup>
<tr>
<td> </td>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
<th>Sun</th>
</tr>
<tr>
<th>1st period</th>
<td>English</td>
<td> </td>
<td> </td>
<td>German</td>
<td>Dutch</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>2nd period</th>
<td>English</td>
<td>English</td>
<td> </td>
<td>German</td>
<td>Dutch</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>3rd period</th>
<td> </td>
<td>German</td>
<td> </td>
<td>German</td>
<td>Dutch</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>4th period</th>
<td> </td>
<td>English</td>
<td> </td>
<td>English</td>
<td>Dutch</td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<thead>
, <tfoot>
, <tbody>
์ฌ์ฉํ์ฌ ๊ตฌ์กฐ ์ถ๊ฐํ๊ธฐ
- ํ ์ด๋ธ์ด ๋ณต์กํด์ง์๋ก ๊ตฌ์กฐ ์ ์๋ฅผ ์ ๊ณตํ๋ ๊ฒ์ด ์ ์ฉํ๋ค.
<thead>
: ๋จธ๋ฆฌ๋ง<tbody>
: ๋ณธ๋ฌธ ์น์ <tfoot>
: ๋ฐ๋ฅ๊ธ
์ ์์๋ค์ ์คํฌ๋ฆฐ๋ฆฌ๋๋ฅผ ํ์ฉํ๋ ์ฌ์ฉ์๋ค์ด table์ ์ ๊ทผํ ์ ์๊ฒํ๊ณ ์๊ฐ์ ํฅ์ ํจ๊ณผ๊ฐ ์๋ค. ํ์ง๋ง, table์ CSS hook์ ์ถ๊ฐํ๋๋ฐ ์ ์ฉํ๋ค.
์๋ฅผ ๋ค์ด, ๊ธด table์ ๊ฒฝ์ฐ ์ธ์๋ ๋ชจ๋ ํ์ด์ง์ table ๋จธ๋ฆฌ๊ธ, ๋ฐ๋ฅ๊ธ์ด ๋ฐ๋ณต๋๋๋ก ํ ์ ์์ผ๋ฉฐ table ๋ณธ๋ฌธ์ ํ ํ์ด์ง์ ํ์ํ๊ณ ์์๋๋ก ์คํฌ๋กคํ์ฌ ๋ด์ฉ์ ๋ณด๋๋ก ํ ์ ์๋ค.
<thead>
- table์์ header ๋ถ๋ถ
<col>
,<colgroup>
์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ<thead>
๋ ๋ฐ๋ก ๊ทธ ์๋ ์์ผ ํ๋ค.
<tbody>
- table์ header, footer ๋ถ๋ถ์ ์ ์ธํ ๋๋จธ์ง ๋ด์ฉ
<tfoot>
- table์์ footer ๋ถ๋ถ
- ์๋ฅผ ๋ค์ด, ์ด์ ํ๋ค์ ํฉ๊ณ๋ฅผ ํ์ํ ์ ์๋ค.
- table์ ๋งจ ์๋์ ํ์ํ๊ฑฐ๋ header ๋ฐ๋ก ์๋์ ํ์ํ ์ ์๋ค.
์ฝ๋์ ์ง์ ํ์ง ์๋๋ผ๋๋ ํญ์ ๋ชจ๋ table์ ํฌํจ๋๋ค. ์ด์ ์์ ์์๋ฅผ ์ ์ํ์ง ์์ ์ฝ๋๋ฅผ ์ด๊ณ ๊ฐ๋ฐ์ ๋๊ตฌ์์ HTML ์ฝ๋๋ฅผ ํ์ธํ๋ฉด ๋ค์๊ณผ ๊ฐ์ด ๋ธ๋ผ์ฐ์ ๊ฐ ์ด ํ๊ทธ๋ฅผ ์ถ๊ฐํ์์ ์ ์ ์๋ค.
Active learning: Adding table structure
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My spending record</title>
<link href="minimal-table.css" rel="stylesheet" type="text/css">
<style>
tbody {
font-size: 95%;
font-style: italic;
}
tfoot {
font-weight: bold;
}
</style>
</head>
<body>
<h1>My spending record</h1>
<table>
<caption>How I chose to spend my money</caption>
<thead>
<tr>
<th>Purchase</th>
<th>Location</th>
<th>Date</th>
<th>Evaluation</th>
<th>Cost (€)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Haircut</td>
<td>Hairdresser</td>
<td>12/09</td>
<td>Great idea</td>
<td>30</td>
</tr>
<tr>
<td>Lasagna</td>
<td>Restaurant</td>
<td>12/09</td>
<td>Regrets</td>
<td>18</td>
</tr>
<tr>
<td>Shoes</td>
<td>Shoeshop</td>
<td>13/09</td>
<td>Big regrets</td>
<td>65</td>
</tr>
<tr>
<td>Toothpaste</td>
<td>Supermarket</td>
<td>13/09</td>
<td>Good</td>
<td>5</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">SUM</td>
<td>118</td>
</tr>
</tfoot>
</table>
</body>
</html>
์ค์ฒฉ Table
์์๋ฅผ ์ด๋ฏธ ๊ตฌ์ฑ๋ ๊ตฌ์กฐ์์ ํฌํจํ์ฌ ํ ํ ์ด๋ธ ๋ด์ ๋ค๋ฅธ ํ ์ด๋ธ์ ์ค์ฒฉ์ํฌ ์ ์๋ค. ์ด๊ฒ์ ์คํฌ๋ฆฐ๋ฆฌ๋ ์ฌ์ฉ์๋ฅผ ํผ๋์ค๋ฝ๊ฒ ํ ์ ์๊ธฐ ๋๋ฌธ์ ์ผ๋ฐ์ ์ผ๋ก ๊ถ์ฅ๋์ง ์๋๋ค. ๋๋ถ๋ถ์ ๊ฒฝ์ฐ ๊ธฐ์กด ํ ์ด๋ธ์ ์ /ํ/์ด๋ง ์ฝ์ ํ๋ ๊ฒ์ด ์ข๋ค. ๊ทธ๋ผ์๋ ๋ถ๊ตฌํ๊ณ ์ฌ์ฉํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ ์ ์๋ค.
<table id="table1">
<tr>
<th>title1</th>
<th>title2</th>
<th>title3</th>
</tr>
<tr>
<td id="nested">
<table id="table2">
<tr>
<td>cell1</td>
<td>cell2</td>
<td>cell3</td>
</tr>
</table>
</td>
<td>cell2</td>
<td>cell3</td>
</tr>
<tr>
<td>cell4</td>
<td>cell5</td>
<td>cell6</td>
</tr>
</table>
์๊ฐ์ฅ์ ์ธ์ ์ํ Table
์ด๊ณผ ํ header ์ฌ์ฉํ๊ธฐ
- ์คํฌ๋ฆฐ๋ฆฌ๋๋ ๋ชจ๋ header๋ฅผ ์๋ณํ๊ณ ๊ทธ header์ ๊ด๋ จ๋ ์ ์ ์ฐ๊ฒฐํ๋ค.
<th>
scope ์์ฑ ์ฌ์ฉํ๊ธฐ
- ๊ฐ
row
col
colgroup
rowgroup
- ์คํฌ๋ฆฐ๋ฆฌ๋์๊ฒ ํด๋น header๊ฐ ์ ํํ ์ด๋ค ์ ์ header์ธ์ง ์๋ ค์ฃผ๊ธฐ ์ํ ์์ฑ์ด๋ค.
- ์ด header
<thead>
<tr>
<th scope="col">Purchase</th>
<th scope="col">Location</th>
<th scope="col">Date</th>
<th scope="col">Evaluation</th>
<th scope="col">Cost (€)</th>
</tr>
</thead>
- ํ header
<tr> <th scope="row">Haircut</th> <td>Hairdresser</td> <td>12/09</td> <td>Great idea</td> <td>30</td> </tr>
id
์ headers
์์ฑ ์ฌ์ฉํ๊ธฐ
- ๊ฐ
<th>
์์์ ๊ณ ์id
๋ฅผ ์ถ๊ฐํ๋ค. - ๊ฐ
<td>
์์์headers
์์ฑ์ ์ถ๊ฐํ๋ค.- ํด๋น ์
์ header ์ญํ ์ ํ๋ ๋ชจ๋
<th>
์์์id
๋ชฉ๋ก์ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถํ์ฌ ํฌํจํ๋ค.<thead> <tr> <th id="purchase">Purchase</th> <th id="location">Location</th> <th id="date">Date</th> <th id="evaluation">Evaluation</th> <th id="cost">Cost (€)</th> </tr> </thead> <tbody> <tr> <th id="haircut">Haircut</th> <td headers="location haircut">Hairdresser</td> <td headers="date haircut">12/09</td> <td headers="evaluation haircut">Great idea</td> <td headers="cost haircut">30</td> </tr>
- ํด๋น ์
์ header ์ญํ ์ ํ๋ ๋ชจ๋
Active learning: playing with scope and headers
scope
ํ์ฉ<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Items sold summary</title> <link href="minimal-table.css" rel="stylesheet" type="text/css"> </head> <body> <h1>Items sold summary</h1> <table> <caption>Items Sold August 2016</caption> <thead> <tr> <td> </td> <td> </td> <th colspan="3" scope="colgroup">Clothes</th> <th colspan="2" scope="colgroup">Accessories</th> </tr> <tr> <td> </td> <td> </td> <th scope="col">Trousers</th> <th scope="col">Skirts</th> <th scope="col">Dresses</th> <th scope="col">Bracelets</th> <th scope="col">Rings</th> </tr> </thead> <tbody> <tr> <th rowspan="3" scope="rowgroup">Belgium</th> <th scope="row">Antwerp</th> <td>56</td> <td>22</td> <td>43</td> <td>72</td> <td>23</td> </tr> <tr> <th scope="row">Gent</th> <td>46</td> <td>18</td> <td>50</td> <td>61</td> <td>15</td> </tr> <tr> <th scope="row">Brussels</th> <td>51</td> <td>27</td> <td>38</td> <td>69</td> <td>28</td> </tr> <tr> <th rowspan="2" scope="rowgroup">The Netherlands</th> <th scope="row">Amsterdam</th> <td>89</td> <td>34</td> <td>69</td> <td>85</td> <td>38</td> </tr> <tr> <th scope="row">Utrecht</th> <td>80</td> <td>12</td> <td>43</td> <td>36</td> <td>19</td> </tr> </tbody> </table> </body> </html>
'Web > HTML' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[HTML] HTML table basics (0) | 2022.07.27 |
---|---|
[HTML] Adding vector graphics to the web (0) | 2022.07.22 |
[HTML] From object to iframe - other embedding technologies (0) | 2022.07.21 |
[HTML] Video and audio content (0) | 2022.07.20 |
[HTML] Images in HTML (0) | 2022.07.19 |