萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網頁製作 >> HTML5 教學

HTML5 重新定義 <b> 與 <i> 標籤:從純表現到語義化

在 Web 標準早期,<b>(粗體)與 <i>(斜體)被視為「純表現、無語意」而遭棄用,建議改用 <strong>(強調重要性)與 <em>(強調語氣)。但 HTML5 工作草案賦予它們全新的語義定義,使其在特定語境下成為正確選擇。

HTML5 規範定義

<b> 元素:關鍵字/產品名/實體名等「文體上區隔」但無額外重要性

The b element now represents a span of text to be stylistically offset from the normal prose without conveying any extra importance, such as key words in a document abstract, product names in a review, or other spans of text whose typical typographic presentation is emboldened.

中文意譯: <b> 表示在正常散文中僅從文體上區隔、不傳達額外重要性的一段文字。例如:文檔摘要中的關鍵字、評論中的產品名、或慣以粗體呈現的其他文字片段。

<i> 元素:異語/術語/思想/船名等「語氣/聲音轉換」

The i element now represents a span of text in an alternate voice or mood, or otherwise offset from the normal prose, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, a thought, a ship name, or some other prose whose typical typographic presentation is italicized.

中文意譯: <i> 表示在正常散文中以不同聲音/語氣呈現、或以其他方式區隔的一段文字。例如:分類學名稱、技術術語、外語慣用語、內心獨白、船名、或慣以斜體呈現的其他文字。用法隨語言差異極大。

四大語義標籤對比表

標籤語義核心典型場景視覺預設
<strong>重要性/嚴重性/緊急性警告、錯誤訊息、關鍵步驟粗體
<b>文體區隔(關鍵字、實體名)摘要關鍵字、產品名、專有名詞粗體
<em>語氣強調(改變句意重音)「我沒有說他偷錢」(語氣重點)斜體
<i>聲音/語氣切換(術語、外語、思想)學名 Homo sapiens、外語 c'est la vie、內心獨白斜體

實務用法範例

<article>
  <header>
    <h1><b>HTML5</b> 語義化標籤指南</h1>
  </header>
  <p>在 <b>HTML5</b> 中,<b><b></b></b> 與 <b><i></b></b> 獲得新語義。</p>
  <p>生物學名稱採用 <i>Homo sapiens</i> 格式。</p>
  <p>法文片語 <i>c'est la vie</i> 意為「生活就是這樣」。</p>
  <p><strong>警告</strong>:請勿濫用 <b> 與 <i> 取代 <strong>/<em>。</p>
</article>

CSS 樣式建議

/* 保留預設粗體/斜體,或依設計系統調整 */
b { font-weight: 600; }          /* 比 normal 粗,比 strong 輕 */
i { font-style: italic; }
strong { font-weight: 700; }
em { font-style: italic; }

決策流程圖

  1. 是否要表達重要性/警示?→ <strong>
  2. 是否要表達語氣重音?→ <em>
  3. 是否為關鍵字/產品名/實體名(文體區隔)?→ <b>
  4. 是否為術語/外語/思想/船名(聲音切換)?→ <i>
  5. 單純視覺粗體/斜體無語意?→ CSS font-weight/font-style 或 <span> + class。
HTML5 讓 <b>/<i> 從「被棄用的表現標籤」轉身為「精準的語義標籤」,關鍵在於理解其語義邊界,避免濫用取代 <strong>/<em>。
copyright © 萬盛學電腦網 all rights reserved