HTML 入門門檻極低,但要從「會寫標籤」進化為「寫出優雅、可維護、無障礙、SEO 友善的結構」,需要刻意練習與正確心法。以下是經實戰驗證的高效學習路徑:
Live Server (即時預覽)、Prettier (格式化)、HTMLHint/Markuplint (靜態檢查)、Emmet (內建,輸入 `!` + Tab 產生骨架)。💡 核心心法:**「閱讀優秀代碼 > 閱讀教學文檔」**。真實專案代碼包含命名慣例、無障礙屬性、SEO 佈局、響應式結構等隱性知識。
不需背誦所有 100+ 標籤。集中火力掌握 **高頻 20% 標籤解決 80% 場景**:
| 類別 | 必會標籤 | 核心屬性 |
|---|---|---|
| 文件結構 | `html, head, body, title, meta, link, script` | `lang`, `charset`, `name/content`, `href/rel`, `src/defer` |
| 文字語意 | `h1-h6, p, strong, em, blockquote, cite, code, pre, mark, time, address` | - |
| 列表/群組 | `ul, ol, li, dl, dt, dd` | - |
| 連結/媒體 | `a, img, picture, source, video, audio, iframe` | `href, target, rel, src, alt, width/height, loading, controls` |
| 表單 | `form, input, textarea, select, option, button, label, fieldset, legend, datalist` | `type, name, value, placeholder, required, disabled, autocomplete, for` |
| 表格 | `table, thead, tbody, tfoot, tr, th, td, caption` | `scope, colspan, rowspan` |
| 語意化區塊 (HTML5) | `header, nav, main, article, section, aside, footer, figure, figcaption, details, summary` | - |
| 通用容器 | `div, span` | `class, id, data-*, aria-*` |
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="頁面摘要,150字內,含核心關鍵字">
<meta property="og:title" content="分享標題">
<meta property="og:description" content="分享描述">
<meta property="og:image" content="https://example.com/og.jpg">
<meta property="og:url" content="https://example.com/page">
<meta name="twitter:card" content="summary_large_image">