| 標籤 | 描述 | 關鍵屬性 |
|---|---|---|
<!DOCTYPE html> | HTML5 文件類型宣告 | — |
<html> | 根元素 | lang |
<head> | 元資料容器 | — |
<title> | 文件標題 | — |
<meta> | 元資料 | charset, name, content, http-equiv |
<link> | 外部資源連結 | rel, href, type, media |
<style> | 內部樣式 | type, media |
<script> | 腳本 | src, async, defer, type |
<body> | 文件主體 | onload, onunload (事件屬性) |
| 標籤 | 語義 | 典型用途 |
|---|---|---|
<header> | 頁首/區塊標題群 | Logo、導航、搜尋 |
<nav> | 主要導航 | 選單、麵包屑 |
<main> | 主要內容 (唯一) | 文章、產品詳情 |
<article> | 獨立完整內容 | 部落格文、新聞、評論 |
<section> | 主題性區塊 | 章節、標籤頁面板 |
<aside> | 側邊/附加資訊 | 側邊欄、廣告、相關連結 |
<footer> | 頁尾/區塊尾部 | 版權、聯絡、站點地圖 |
<div> | 無語義通用容器 | 樣式/JS 掛鉤、最後手段 |
| 標籤 | 語義 | 預設樣式 |
|---|---|---|
<a> | 超連結 | 底線、藍色 |
<strong> | 重要性強調 | 粗體 |
<em> | 語氣強調 | 斜體 |
<b> | 視覺粗體 (無語義) | 粗體 |
<i> | 視覺斜體/慣用語/專有名詞 | 斜體 |
<u> | 標註 (錯字、中文專有名號) | 底線 |
<mark> | 高亮標記 | 黃底 |
<small> | 細節/免責聲明 | 小字 |
<del>/<ins> | 刪除/插入 | 刪除線/底線 |
<sub>/<sup> | 下標/上標 | 縮小上下移 |
<code> | 程式碼片段 | 等寬字體 |
<kbd> | 鍵盤輸入 | 等寬字體 |
<samp> | 程式輸出 | 等寬字體 |
<var> | 變數 | 斜體 |
<cite> | 著作標題 | 斜體 |
<q> | 短引用 (自動加引號) | 引號 |
<abbr> | 縮寫 (配合 title) | 底虛線 |
<dfn> | 定義術語 | 斜體 |
<time> | 日期時間 (datetime) | — |
<data> | 機器可讀數值 (value) | — |
<ruby>/<rt>/<rp> | 注音/拼音 | — |
<bdi>/<bdo> | 雙向文字隔離/覆寫 | — |
<span> | 無語義行內容器 | — |
<br> | 換行 | — |
<wbr> | 建議斷詞機會 | — |
| 標籤 | 用途 |
|---|---|
<ul> | 無序清單 |
<ol> | 有序清單 (reversed, start, type) |
<li> | 清單項目 (value) |
<dl> | 定義清單 |
<dt> | 定義術語 |
<dd> | 定義描述 |
| 標籤 | 關鍵屬性 |
|---|---|
<img> | src, alt (必填), width, height, loading, decoding, srcset, sizes |
<picture> | 容器,含多個 <source> + 1 個 <img> |
<source> | srcset, media, type |
<video> | src, controls, autoplay, loop, muted, poster, preload |
<audio> | src, controls, autoplay, loop, muted, preload |
<track> | kind, src, srclang, label, default |
<canvas> | width, height (JS 繪圖) |
<svg> | 向量圖形 (內嵌 XML) |
<map>/<area> | 圖像地圖 (shape, coords, href, alt) |
| 標籤 | 關鍵屬性 |
|---|---|
<form> | action, method (GET/POST), enctype, novalidate, target |
<input> | type (text/email/password/number/date/checkbox/radio/file/hidden/submit/button/color/range...), name, value, placeholder, required, disabled, readonly, autocomplete, pattern, min, max, step, list |
<textarea> | name, rows, cols, placeholder, required, maxlength, wrap |
<select> | name, multiple, size, required, disabled |
<option> | value, selected, disabled, label |
<optgroup> | label, disabled |
<button> | type (submit/reset/button), name, value, disabled, formaction, formmethod |
<label> | for (對應 input id), 內容模型包裹 input |
<fieldset>/<legend> | 群組相關欄位 |
<datalist> | id (供 input list 參考) |
<output> | for (關聯輸入 id), name |
<meter> | value, min, max, low, high, optimum |
<progress> | value, max |
| 標籤 | 關鍵屬性 |
|---|---|
<table> | border, cellpadding, cellspacing (建議改 CSS) |
<caption> | 表格標題 |
<thead>/<tbody>/<tfoot> | 表格區段 |
<tr> | 列 |
<th> | 表頭 (scope="col|row|colgroup|rowgroup", abbr) |
<td> | 資料 (colspan, rowspan, headers) |
<colgroup>/<col> | 欄群組/欄屬性 (span, width) |
| 標籤 | 用途 |
|---|---|
<details>/<summary> | 原生摺疊面板 (無需 JS) |
<dialog> | 原生對話框 (showModal()) |
<slot> | Web Components 插槽 |
<template> | HTML 模板 (JS 實例化) |
<script> | JavaScript (module/defer/async) |
<noscript> | 無 JS 環境替代內容 |
<font>, <center>, <strike>, <big>, <tt>, <frame>, <frameset>, <noframes>, <acronym>, <applet>, <isindex>, <dir>, <basefont>。align, bgcolor, border (於 table), width/height (非 img/video/canvas), scrolling, valign, cellpadding, cellspacing 等表現屬性。