HTML 文檔三大區塊:<head>(元資料)、<body>(主體內容)、<html>(根元素)。標籤成對出現,建議完整閉合。支援內嵌 CSS(<style>)與 Script(<script>)增強互動。
| 標籤 | 用途 |
|---|---|
<h1>–<h6> | 標題層級,h1 最大、h6 最小,語意化結構關鍵 |
<p> | 段落,可帶 align 屬性 |
<br> | 強制換行(空元素) |
<div> | 區塊容器,配合 CSS 佈局威力最大 |
<hr> | 水平分隔線 |
<strong>、<em>、<code>、<cite>、<ins>/<del> — 表達含義,跨瀏覽器穩定<b>、<i>、<big>、<small>、<sub>/<sup> — 僅控制外觀推薦使用邏輯標籤,語意更清晰、無障礙友善。
<a>href="https://..."、ftp://、mailto:file.html、上層 ../file.html<a href="#top">回頂部</a> + <a id="top"></a><img><img src="pic.gif" alt="替代文字" width="100" height="100" border="1" hspace="5" vspace="5" />
alt:圖片無法載入時顯示,無障礙必備<ul>: type="disc|circle|square"<ol>: type="1|a|A|i|I"、start 指定起始編號<dl>: <dt> 術語 + <dd> 定義描述列表可巢狀嵌套構成樹狀選單。
<form><form action="..." method="post">
<input type="text" name="username" />
<input type="password" name="pwd" />
<textarea rows="3" cols="20"></textarea>
<input type="submit" value="送出" />
<input type="reset" value="重填" />
</form>
輸入類型:文字、密碼、單選 radio、複選 checkbox、下拉 select/option、多選 select multiple。
<frameset>/<frame>(已淘汰)將頁面分割為多個獨立框架,各自載入不同文檔。HTML5 已移除,現代開發請改用 AJAX、iframe 或 SPA 架構。