HTML(HyperText Markup Language,超文本標記語言)是 Web 頁面的骨架。理解標籤的全稱與語義,能編寫更結構化、可維護、無障礙友好的代碼。
<html>
<head> <!-- 文檔元數據:標題、編碼、樣式、腳本 -->
<title>頁面標題</title>
<meta charset="UTF-8">
</head>
<body> <!-- 可見內容區域 -->
<h1>主標題</h1>
<p>段落內容</p>
</body>
</html>
| 標籤 | 全稱/含義 | 語義用途 |
|---|---|---|
<html> | HTML Document | 文檔根元素 |
<head> | Head | 元數據容器 |
<body> | Body | 主體內容 |
<h1>-<h6> | Heading 1-6 | 標題,h1 最高級 |
<p> | Paragraph | 段落 |
<div> | Division | 塊級容器,無語義 |
<span> | Span | 行內容器,無語義 |
<a> | Anchor | 超鏈接 |
<img> | Image | 圖片 |
<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 | 按鈕 |
<select> | Select | 下拉選單 |
<textarea> | Text Area | 多行文本輸入 |
| 標籤 | 全稱 | 使用場景 |
|---|---|---|
<header> | Header | 頁面/區塊頂部 |
<nav> | Navigation | 導航鏈接組 |
<main> | Main | 主要內容(唯一) |
<article> | Article | 獨立完整內容 |
<section> | Section | 主題性內容分組 |
<aside> | Aside | 側邊欄/輔助信息 |
<footer> | Footer | 頁面/區塊底部 |
<figure> | Figure | 圖表/代碼/圖片組 |
<figcaption> | Figure Caption | figure 標題 |
<time> | Time | 日期時間 |
<mark> | Mark | 高亮文本 |
<nav> 而非 <div class="nav">深入理解 HTML 標籤語義,是成為優秀前端工程師的基石,也是構建高質量 Web 應用的起點。