HTML 標籤是網頁的構建塊。本文釐清定義、大小寫規則、語意化原則與常見分類,建立正確標記觀念。
<body>...</body> <!-- 推薦:全小寫 -->
<BODY>...</BODY> <!-- 合法但不推薦 -->
<Body>...</Body> <!-- 合法但不推薦 -->
<strong> 而非 <b> 或 <span style="font-weight:bold">)header, footer, main, section, article, aside, nav, figure, figcaption, time, mark<div>、<span>(無語意容器)| 分類 | 代表標籤 |
|---|---|
| 文件結構 | html, head, body, title, meta, link, style, script |
| 文字語意 | h1-h6, p, strong, em, blockquote, cite, code, mark, time |
| 佈局分組 | div, span, header, footer, main, section, article, aside, nav |
| 列表 | ul, ol, li, dl, dt, dd |
| 表格 | table, caption, thead, tbody, tfoot, tr, th, td |
| 表單 | form, input, textarea, select, option, button, label, fieldset |
| 多媒體 | img, picture, audio, video, source, canvas, svg, iframe |
| 互動/連結 | a, button, details, summary, dialog |
area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr — 無結束標籤,HTML5 可寫 <br> 或 <br />。