HTML 是 Web 開發的基石,但「會寫幾個標籤」與「寫出專業級 HTML」有巨大鴻溝。本文提供結構化、階段性、實戰導向的完整學習路線圖,助你從零建立扎實前端根基。
階段 0:環境與工具 (Day 1)
- **編輯器:** VS Code (必裝擴充:Live Server, Prettier, HTMLHint/Markuplint, Emmet, Auto Rename Tag, IntelliSense for CSS class names)
- **瀏覽器:** Chrome/Edge DevTools 精通 (Elements, Console, Network, Performance, Lighthouse, Accessibility, Rendering)
- **版控:** Git + GitHub (建立 repo、commit、push、PR、GitHub Pages 部署)
- **終端機:** 基本指令 (`ls`, `cd`, `mkdir`, `npm`, `npx`)
階段 1:核心語法與文件結構 (Week 1-2)
- **標準骨架:** ``, ``, `` (meta charset/viewport/title/description/OG), ``
- **高頻標籤分類掌握 (20% 標籤解決 80% 場景):**
- 文字語意:`h1-h6`, `p`, `strong`, `em`, `blockquote`, `cite`, `code`, `pre`, `mark`, `time`, `abbr`, `ruby/rt/rp`
- 列表:`ul`, `ol`, `li`, `dl`, `dt`, `dd`
- 連結/媒體:`a` (href/target/rel/download), `img` (src/alt/width/height/loading/srcset/sizes), `picture/source`, `video`, `audio`, `iframe`
- 表單:`form`, `input` (type/name/value/placeholder/required/disabled/readonly/autocomplete/list), `textarea`, `select/option/optgroup`, `button`, `label` (for), `fieldset/legend`, `datalist`, `output`, `progress`, `meter`
- 表格:`table`, `caption`, `thead/tbody/tfoot`, `tr`, `th` (scope), `td`, `colgroup/col`
- 語意區塊:`header`, `nav`, `main`, `article`, `section`, `aside`, `footer`, `figure`, `figcaption`, `details/summary`, `dialog`
- 通用容器:`div`, `span` (最後手段)
- **屬性精通:** 全域屬性 (`id`, `class`, `style`, `data-*`, `aria-*`, `hidden`, `tabindex`, `contenteditable`, `title`)、專有屬性、布林屬性 (`disabled`, `readonly`, `required`, `hidden`, `multiple`, `autofocus`)、事件屬性 (認知即可,實務用 `addEventListener`)。
- **實體編碼:** `<`, `>`, `&`, `"`, `'`, ` `, ` `, ` `, ``。
- **驗證習慣:** 每存檔即 `W3C Validator` / `HTMLHint` / `Markuplint` 檢查,紅錯誤零容忍。
階段 2:語意化、無障礙、SEO 三位一體 (Week 3-4)
- **語意化決策樹:** 遇到 `
`/`
` 必問:「有語意標籤能取代嗎?」
- **文件大綱:** 單一 `
`、層級不跳級 (h1→h2→h3)、`section`/`article` 重置大綱 (HTML5 Outline Algorithm 雖未完全實作,但語意結構仍關鍵)。
- **ARIA 基礎:** `role` (button, dialog, navigation, search, alert, region)、`aria-label/labelledby/describedby`, `aria-hidden`, `aria-expanded`, `aria-controls`, `aria-live` (polite/assertive)、`aria-current` (導覽當前頁)。**原生標籤優先,ARIA 補足。**
- **鍵盤導航:** `Tab` 順序邏輯、焦點可見 (`:focus-visible`)、`Skip to main content` 連結、Modal 焦點陷阱、ESC 關閉。
- **螢幕閱讀器實測:** NVDA (Win) / VoiceOver (Mac/iOS) / TalkBack (Android) / Orca (Linux)。
- **SEO 技術優化:** Title/Description/OG/Twitter Card/Canonical/JSON-LD Schema.org (Article, Product, Breadcrumb, FAQ, Organization, WebSite)、語意化結構、載入速度、行動友善、HTTPS、Sitemap/Robots.txt。
階段 3:現代 HTML5 API 與進階特性 (Week 5-6)
階段 4:效能工程與 Core Web Vitals (Week 7-8)
- **關鍵渲染路徑優化:** 關鍵 CSS 內聯、非關鍵 CSS 延遲、JS `defer`/`module`、字體 `preload` + `font-display: swap`、資源提示 (`preconnect`, `dns-prefetch`, `prefetch`, `prerender`)。
- **圖片極致優化:** WebP/AVIF、響應式 `srcset`/`sizes`、`` 藝術導向、`loading="lazy"` (非 LCP 圖)、`width`/`height` 預留、CDN 圖片服務 (Cloudinary, Imgix, 自建)。
- **第三方腳本治理:** `async`/`defer`、Partytown (Web Worker 執行)、延遲載入、審計必要性。
- **Lighthouse CI / WebPageTest / CrUX 真實用戶數據監控**。
- **HTTP/2/3、壓縮、快取策略、Service Worker 离線/預取**。
階段 5:現代工具鏈與框架整合 (Week 9+)
- **建置工具:** Vite (極速、ESM 原生、HMR、插件生態)、Astro (內容導向、零 JS、島嶼架構)、esbuild (極速打包)。
- **框架選擇:** Vue 3 (Composition API、SFC、生態成熟)、React 18 (Concurrent、Server Components)、Svelte 5 (Runes、編譯時優化)、Solid (細粒度響應、無 Virtual DOM)、Qwik (Resumable、零水合)。
- **全棧/邊緣:** Next.js (App Router, RSC, Server Actions)、Nuxt 3、Remix、Hono、Fresh、Astro + 後端 API。
- **測試:** Vitest (單元/整合)、Playwright (E2E、跨瀏覽器、視覺回歸)、Storybook (組件文檔/測試)、axe-core (a11y 自動化)。
- **代碼品質:** ESLint + @html-eslint/parser、Stylelint、Prettier、Markuplint、TypeScript (嚴格模式)、Husky + lint-staged (Git Hooks)。
- **部署:** 靜態站點 → Cloudflare Pages / Netlify / Vercel / GitHub Pages / AWS S3+CloudFront。SSR/Edge → Vercel / Netlify / Cloudflare Workers / Deno Deploy / Fly.io。
持續精進:終身學習清單
- 追蹤 HTML Living Standard 更新 (GitHub `whatwg/html` commits、WHATWG Blog)。
- 關注 Chrome Platform Status、WebKit Blog、Mozilla Hacks、web.dev 新特性落地。
- 參與 W3C/WHATWG Issue 討論、提交 Bug Report、貢獻 Polyfill。
- 建立**個人元件庫/設計系統** (Storybook + Chromatic + npm 發布)。
- 輸出技術文章、開源專案、分享會,以教代學、建立影響力。
HTML 學無止境。從「會用標籤」到「懂解析器、懂語意、懂無障礙、懂效能、懂工程化、懂架構」,每一步都在拓寬你對 Web 平台本質的理解。保持好奇,持續構建,享受編織數位世界的樂趣。