萬盛學電腦網

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

HTML 標籤完整分類參考:結構、文字、列表、表格、表單、媒體、腳本等核心標籤速查手冊

HTML5 標籤分類速查:建立正確的語意化標記思維

HTML 標籤超過 100 種,掌握分類與核心屬性是前端基礎。本文依功能分類整理高頻標籤,附關鍵屬性與語意說明。

1. 文件結構標籤

  • <!DOCTYPE html>:宣告 HTML5 文件型別,啟用 Standards Mode
  • <html>:根元素,lang="zh-Hant" 指定語言
  • <head>:元資料容器(標題、編碼、樣式、腳本、SEO、圖示)
  • <body>:可見內容容器
  • <title>:文件標題(瀏覽器分頁、書籤、SEO 關鍵)
  • <meta>:編碼 (charset="utf-8")、視口 (viewport)、SEO、社群分享
  • <link>:外部資源(CSS、預載入、圖示、預連接)
  • <style>、<script>:內嵌樣式/腳本

2. 區塊語意結構標籤 (HTML5 Sectioning)

  • <header>、<footer>、<main>、<nav>、<aside>、<section>、<article>
  • <div>:無語意通用容器(最後手段)

3. 文字內容標籤

  • 標題:<h1>~<h6>(單頁僅一 h1,嚴格階層)
  • 段落:<p>
  • 換行:<br>(空元素,僅限詩歌/地址等必須換行處)
  • 引用:<blockquote> (區塊)、<q> (行內)、<cite> (作品標題)
  • 強調:<strong> (重要)、<em> (語氣強調)、<mark> (標記/高亮)
  • 修飾:<small> (細則)、<del>/<ins> (刪改)、<sub>/<sup> (下/上標)
  • 程式碼:<code>、<pre> (預格式)、<kbd> (鍵盤輸入)、<samp> (程式輸出)、<var> (變數)
  • 時間:<time datetime="2024-01-01">
  • 換行機會:<wbr>

4. 列表標籤

  • 無序:<ul> > <li>
  • 有序:<ol> > <li> (屬性 reversed, start, type)
  • 定義/描述:<dl> > <dt> (術語) + <dd> (描述)

5. 表格標籤

  • <table>、<caption>、<thead>、<tbody>、<tfoot>
  • <tr>、<th> (標題儲存格)、<td> (資料儲存格)
  • <colgroup>、<col> (欄群組/樣式)
  • 屬性:scope="col|row|colgroup|rowgroup" (無障礙關鍵)

6. 表單標籤

  • <form> (屬性 action, method, novalidate)
  • <label> (綁定 for="id" 或包裹 input)
  • <input> (type: text, email, password, number, date, checkbox, radio, file, hidden, submit, button, color, range 等)
  • <textarea>、<select> > <option> / <optgroup>
  • <button> (type: submit, reset, button)、<fieldset>/<legend>、<datalist>、<output>
  • 驗證屬性:required, pattern, min/max, minlength/maxlength

7. 媒體與嵌入標籤

  • 圖片:<img> (src, alt, loading="lazy", srcset, sizes)
  • 圖片容器:<picture> > <source> (響應式圖片/格式降級)
  • 影音:<video>, <audio> > <source>, <track> (字幕)
  • 嵌入:<iframe>, <embed>, <object>, <param>
  • Canvas/SVG:<canvas>, <svg>

8. 互動與腳本標籤

  • <script> (async, defer, type="module", nomodule)
  • <noscript>、<template>、<slot> (Web Components)
  • <details>/<summary>、<dialog> (原生對話框)

9. 已棄用/不建議使用標籤

<font>, <center>, <big>, <strike>, <tt>, <frameset>, <frame>, <noframes>, <acronym>, <applet>, <isindex>, <dir>, <basefont>, <bgsound>, <blink>, <marquee> 等。請改用 CSS 與語意化標籤替代。

copyright © 萬盛學電腦網 all rights reserved