HTML(HyperText Markup Language)是構建網頁的基石。本文梳理 HTML 核心能力、標籤分類、文件結構,並規劃從 HTML 4.01 邁向 XHTML、CSS、HTML5 的進階學習路徑。
h1-h6)、段落(p)、清單(ul/ol/dl)、引用(blockquote/q)img)、音訊(audio)、影片(video)、Canvas/WebGLa)、內部跳轉、外部資源、Email/電話協議table、thead/tbody/tfoot、th/td、colgroup、captionheader、footer、nav、main、article、section、aside(HTML5 新增)script、style、link、meta<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<title>頁面標題</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>...</header>
<main>...</main>
<footer>...</footer>
<script src="app.js" defer></script>
</body>
</html>
<p>內容</p>,空元素自閉合 <br/>、<img/>name="value",布林屬性可簡寫 disabled<nav> 而非 <div class="nav">,利於 SEO、無障礙、維護<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><link>)、內部(<style>)、內聯(style="")| 新增類別 | 代表標籤/API | 核心價值 |
|---|---|---|
| 語意結構 | header, footer, nav, section, article, aside, main, figure, figcaption, time, mark | 文件大綱清晰、機器可讀 |
| 多媒體原生 | video, audio, source, track | 無需 Flash/Silverlight 外掛 |
| 圖形繪製 | canvas (2D/WebGL)、svg | 瀏覽器原生繪圖、遊戲、視覺化 |
| 表單增強 | input[type=email/date/number/color/range]、datalist、output、驗證 API | 減少 JS 驗證負擔、行動裝置鍵盤自適應 |
| 離線與儲存 | LocalStorage/SessionStorage、IndexedDB、Cache API、Service Worker | PWA 離線應用、效能優化 |
| 通訊與裝置 | WebSocket、WebRTC、Geolocation、Device Orientation、Bluetooth、USB | 即時協作、硬體存取 |