HTML 標籤超過 100 種,掌握分類與核心屬性是前端基礎。本文依功能分類整理高頻標籤,附關鍵屬性與語意說明。
<!DOCTYPE html>:宣告 HTML5 文件型別,啟用 Standards Mode<html>:根元素,lang="zh-Hant" 指定語言<head>:元資料容器(標題、編碼、樣式、腳本、SEO、圖示)<body>:可見內容容器<title>:文件標題(瀏覽器分頁、書籤、SEO 關鍵)<meta>:編碼 (charset="utf-8")、視口 (viewport)、SEO、社群分享<link>:外部資源(CSS、預載入、圖示、預連接)<style>、<script>:內嵌樣式/腳本<header>、<footer>、<main>、<nav>、<aside>、<section>、<article><div>:無語意通用容器(最後手段)<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><ul> > <li><ol> > <li> (屬性 reversed, start, type)<dl> > <dt> (術語) + <dd> (描述)<table>、<caption>、<thead>、<tbody>、<tfoot><tr>、<th> (標題儲存格)、<td> (資料儲存格)<colgroup>、<col> (欄群組/樣式)scope="col|row|colgroup|rowgroup" (無障礙關鍵)<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<img> (src, alt, loading="lazy", srcset, sizes)<picture> > <source> (響應式圖片/格式降級)<video>, <audio> > <source>, <track> (字幕)<iframe>, <embed>, <object>, <param><canvas>, <svg><script> (async, defer, type="module", nomodule)<noscript>、<template>、<slot> (Web Components)<details>/<summary>、<dialog> (原生對話框)<font>, <center>, <big>, <strike>, <tt>, <frameset>, <frame>, <noframes>, <acronym>, <applet>, <isindex>, <dir>, <basefont>, <bgsound>, <blink>, <marquee> 等。請改用 CSS 與語意化標籤替代。