| 語意化標籤(推薦) | 視覺化標籤(慎用/棄用) | 語意 | 預設樣式 | CSS 替代 |
|---|---|---|---|---|
| `` | `` | 重要性強調 | 粗體 | `font-weight: bold` / `700` |
| `` | `` | 語氣強調 | 斜體 | `font-style: italic` |
| `` | — | 標記/高亮 | 黃底 | `background: #ff0; padding: 0.1em` |
| ` | ` | 刪除/不再正確 | 刪除線 | `text-decoration: line-through` |
| `` | `` | 插入/新增 | 底線 | `text-decoration: underline` |
`` | `` | 行內程式碼 | 等寬 | `font-family: monospace` |
| `` | — | 鍵盤輸入 | 等寬+邊框 | `font-family: monospace; border:1px solid #ccc; padding:0.1em 0.3em; border-radius:3px` |
| `` | — | 程式輸出 | 等寬 | `font-family: monospace` |
| `` | — | 變數/引數 | 斜體 | `font-style: italic; font-family: monospace` |
| `` | — | 定義術語 | 斜體 | `font-style: italic` |
| `` | — | 作品引用 | 斜體 | `font-style: italic` |
| `` | `` | 細則/附註 | 較小字 | `font-size: 0.875em` |
| `` / `` | — | 下標/上標 | 縮小上下移 | `vertical-align: sub/super; font-size: 0.75em` |
| ` | — | 機器可讀時間 | 正常 | 無視覺差異,語意/SEO 用 |
| `` | — | 機器可讀資料 | 正常 | 同上 |
| `` | — | 縮寫 | 底虛線(部分) | `border-bottom: 1px dotted; cursor: help` |
`` | — | 行內引用 | 自動引號 | `quotes` 屬性控制引號樣式 |
`` | — | 區塊引用 | 縮排 | `margin: 1em 40px; padding-left: 1em; border-left: 3px solid #ccc` |
| 標籤 | 語意 | 預設大小約 | CSS 重置建議 |
|---|---|---|---|
`` | 最高層級標題(全頁一個) | 2em (32px) | `font-size: 2rem; font-weight: 700; margin: 0.67em 0` |
`` | 二級標題 | 1.5em (24px) | `font-size: 1.5rem; font-weight: 600; margin: 0.83em 0` |
`` | 三級標題 | 1.17em (18.7px) | `font-size: 1.25rem; font-weight: 600; margin: 1em 0` |
`` | 四級標題 | 1em (16px) | `font-size: 1rem; font-weight: 600; margin: 1.33em 0` |
`` | 五級標題 | 0.83em (13.3px) | `font-size: 0.875rem; font-weight: 600; margin: 1.67em 0` |
`` | 六級標題 | 0.67em (10.7px) | `font-size: 0.75rem; font-weight: 600; margin: 2.33em 0` |
| ` ` | 段落 | 1em | `margin: 1em 0; line-height: 1.6` |
`` | 預先格式化文字(保留空白換行) | 等寬、保留格式 | `font-family: monospace; white-space: pre-wrap; overflow-x: auto` |
| ` ` | 主題分隔線 | 水平線 | `border: 0; border-top: 1px solid #ddd; margin: 2em 0` |
| `` | 聯絡資訊 | 斜體 | `font-style: normal; margin: 1em 0` |
<a href="https://example.com" target="_blank" rel="noopener noreferrer" hreflang="en" type="text/html">
連結文字
</a>
/* 連結狀態 CSS 順序:LVHA */
a:link { color: #0066cc; text-decoration: none; }
a:visited { color: #663399; }
a:hover { color: #004499; text-decoration: underline; }
a:active { color: #cc0000; }
a:focus-visible { outline: 2px solid #0066cc; outline-offset: 2px; } /* 鍵盤焦點可見 */
/* 字體族 */
font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
/* 字體大小 */
font-size: 1rem; /* 基礎 16px */
font-size: clamp(1rem, 2vw, 1.5rem); /* 響應式流體排版 */
/* 字體粗細 */
font-weight: 400; /* normal */ 500; 600; 700; /* bold */
/* 行高 */
line-height: 1.6; /* 無單位,繼承為倍數 */
/* 顏色 */
color: #333; /* 十六進位 */
color: rgb(51, 51, 51); /* RGB */
color: hsl(0, 0%, 20%); /* HSL */
color: var(--text-main); /* CSS 變數 */
/* 文字對齊 */
text-align: left | center | right | justify;
/* 文字裝飾 */
text-decoration: underline | overline | line-through | none;
text-decoration-color: red; text-decoration-style: wavy; text-decoration-thickness: 2px;
/* 文字陰影 */
text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
<article>
<header>
<h1>HTML 文字格式化完全指南</h1>
<p><time datetime="2024-01-15">2024-01-15</time> | <a href="/author/john">John</a></p>
</header>
<p><strong>語意化標籤</strong>能讓瀏覽器、搜尋引擎、螢幕閱讀器理解內容結構,而非只看外觀。</p>
<p>例如 <strong> 表示重要,<b> 只是視覺粗體;<em> 表示語氣重音,<em> 只是視覺斜體。</p>
<blockquote cite="https://html.spec.whatwg.org/">
<p>HTML 標準定義了每個元素的語意,作者應依語意選擇元素。</p>
<footer>— <cite>HTML Living Standard</cite></footer>
</blockquote>
<p>按 Ctrl+C 複製,Ctrl+V 貼上。</p>
<footer>
<small>© 2024 作者姓名. <a href="/license">CC BY 4.0</a></small>
</footer>
</article>
掌握語意化文字標籤,配合 CSS 精確控制外觀,才能產出結構優良、無障礙友善、易於維護的現代網頁內容。