表格結構
<table>
<caption>標題</caption>
<thead><tr><th scope="col">表頭</th></tr></thead>
<tbody><tr><td>資料</td></tr></tbody>
<tfoot><tr><td>摘要</td></tr></tfoot>
</table>
列表家族
<!-- 無序列表 -->
<ul><li>項目</li><li>項目</li></ul>
<!-- 有序列表 -->
<ol><li>步驟 1</li><li>步驟 2</li></ol>
<!-- 定義列表 -->
<dl>
<dt>術語</dt><dd>定義</dd>
<dt>HTML</dt><dd>超文本標記語言</dd>
</dl>
通用屬性(Global Attributes)
| 屬性 | 用途 | 範例 |
id | 唯一標識(大小寫敏感) | id="main-nav" |
class | 分類/樣式鉤子 | class="btn btn-primary" |
style | 內聯樣式(優先級高) | style="color:red" |
title | 滑鼠懸停提示 | title="詳細說明" |
data-* | 自訂資料屬性 | data-user-id="123" |
aria-* | 無障礙屬性 | aria-label="關閉" |
行內元素速查
- 媒體:
<img> (src, alt, width, height, loading), <audio>, <video>
- 連結:
<a href=""> (target, rel, download, hreflang)
- 文字語意:
<span>, <strong>, <em>, <mark>, <time>, <sub>, <sup>, <br>
- 表單:
<input>, <button>, <select>, <textarea>, <label>
圖片必要屬性
<img src="photo.webp" alt="描述" width="400" height="300" loading="lazy" decoding="async">
連結完整範例
<a href="/about" class="link" aria-label="關於我們">關於我們</a>
<a href="mailto:contact@example.com?subject=詢問">聯絡我們</a>
<a href="tel:+88621234567">致電客服</a>
<a href="#section2">跳至第二節</a>