HTML(HyperText Markup Language,超文本標記語言)是構建網頁的基石。理解標籤的英文全拼來源,不僅能加深記憶,更能掌握其語義設計初衷。本文從文檔結構、標籤分類、巢狀規則三大面向,帶你建立扎實的HTML核心觀念。
<!DOCTYPE html> <html lang="zh-Hant"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>文檔標題</title> </head> <body> <!-- 可見內容區塊 --> </body> </html>
| 區塊 | 標籤 | 全拼 | 功能 |
|---|---|---|---|
| 文檔頭部 | <head> | head | 元資料:字編、視口、標題、CSS/JS連結、SEO標籤、Favicon等,不直接顯示於畫面 |
| 文檔主體 | <body> | body | 所有使用者可見內容:文字、圖片、表單、影音、導航、側邊欄等 |
HTML標籤命名遵循兩種模式:
<blockquote> (block quote)、<caption>、<address>、<article>、<section>、<header>、<footer>、<nav>、<figure>、<figcaption>、<details>、<summary>、<datalist>、<optgroup>、<fieldset>、<legend>、<caption><p> (paragraph)、<div> (division)、<span>、<img> (image)、<a> (anchor)、<ul> (unordered list)、<ol> (ordered list)、<li> (list item)、<dl> (definition list)、<dt> (definition term)、<dd> (definition data)、<tr> (table row)、<td> (table data)、<th> (table header)、<br> (break)、<hr> (horizontal rule)、<em> (emphasize)、<strong>、<var> (variable)、<sub> (subscript)、<sup> (superscript)成對標籤:內容包裹於開啟/關閉標籤間
<p>段落內容</p> <div class="card"><h3>標題</h3><p>內文</p></div> <a href="https://example.com">連結文字</a>
空元素:無內容、無關閉標籤,HTML5可省略斜線
<img src="photo.jpg" alt="風景照"> <br> <hr> <input type="text" name="username"> <meta charset="UTF-8"> <link rel="stylesheet" href="style.css"> <area shape="rect" coords="0,0,100,100" href="link.html"> <base href="https://example.com/"> <col span="2"> <embed src="video.mp4"> <param name="quality" value="high"> <source src="audio.ogg" type="audio/ogg"> <track kind="subtitles" src="sub.vtt" srclang="zh"> <wbr>
| 標籤 | 全拼/來源 | 中文語義 |
|---|---|---|
| <html> | HyperText Markup Language | HTML文檔根元素 |
| <head> | head | 文檔頭部/元資料區 |
| <body> | body | 文檔主體/可見內容區 |
| <h1>-<h6> | heading 1-6 | 一至六級標題 |
| <p> | paragraph | 段落 |
| <a> | anchor | 錨點/超連結 |
| <img> | image | 圖片 |
| <div> | division | 區塊容器 |
| <span> | span | 行內範圍 |
| <ul> | unordered list | 無序列表 |
| <ol> | ordered list | 有序列表 |
| <li> | list item | 列表項目 |
| <table> | table | 表格 |
| <tr> | table row | 表格列 |
| <td> | table data | 資料儲存格 |
| <th> | table header | 表頭儲存格 |
| <form> | form | 表單 |
| <input> | input | 輸入欄位 |
| <button> | button | 按鈕 |
| <label> | label | 標籤/說明文字 |
| <select> | select | 下拉選單 |
| <option> | option | 選項 |
| <textarea> | text area | 多行文字區 |
| <header> | header | 頁首/區塊標題區 |
| <footer> | footer | 頁尾/區塊底部區 |
| <nav> | navigation | 導航區塊 |
| <main> | main | 主要內容區塊 |
| <article> | article | 獨立文章單元 |
| <section> | section | 主題區段 |
| <aside> | aside | 側邊/附加資訊區 |
| <figure> | figure | 圖文/代碼/圖表獨立單元 |
| <figcaption> | figure caption | figure標題/說明 |
| <blockquote> | block quote | 區塊引用 |
| <cite> | citation | 引用來源/書名 |
| <code> | code | 程式碼 |
| <pre> | preformatted | 預格式化文本 |
| <mark> | mark | 標記/高亮 |
| <time> | time | 日期時間 |
| <video> | video | 影片 |
| <audio> | audio | 音訊 |
| <canvas> | canvas | 畫布 |
| <iframe> | inline frame | 內嵌框架 |
<body> 區塊加入內容:<h1>你好,世界!</h1><p>這是我的第一個網頁。</p>index.html(副檔名 .html 或 .htm 均可),編碼選 UTF-8<div><p>...</p></div> ✓ / <div><p>...</div></p> ✗掌握標籤全拼與文檔結構,是邁向前端工程師的第一步。建議動手實作幾個簡單頁面,體會標籤巢狀與語義化的實際效果!