<head> 雖不直接顯示,卻掌控 SEO、編碼、快取、樣式/腳本載入、頁面切換特效等關鍵行為,是網頁的「大腦」。
<base><base href="https://example.com/" target="_blank">
href:所有相對連結/資源的基準 URL。target:預設連結開啟方式(_blank 新分頁、_self 當前頁)。href="#section" 也會受 base href 影響,需謹慎使用。| name 值 | 用途 | 範例 |
|---|---|---|
keywords | 關鍵字 | <meta name="keywords" content="HTML, CSS, 教學"> |
description | 頁面描述 | <meta name="description" content="學習 HTML Head 區塊完整指南..."> |
author | 作者 | <meta name="author" content="張三"> |
generator | 產生工具 | <meta name="generator" content="VS Code"> |
robots | 搜尋機器人指令 | <meta name="robots" content="index,follow">(all/index/follow/noindex/nofollow) |
| 值 | 用途 | 範例 |
|---|---|---|
content-type | 編碼宣告 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
refresh | 自動重導/重整 | <meta http-equiv="refresh" content="5;url=https://example.com">(5 秒後跳轉) |
expires | 快取過期 | <meta http-equiv="expires" content="Wed, 10 Mar 2027 12:00:00 GMT"> |
cache-control | 快取控制 | <meta http-equiv="cache-control" content="no-cache"> |
set-cookie | 設定 Cookie | <meta http-equiv="set-cookie" content="name=value; expires=..."> |
<style type="text/css"> /* 內嵌樣式 */ </style>
<link rel="stylesheet" href="style.css"> /* 外部樣式表,推薦 */
<script type="text/javascript"> /* 內嵌腳本 */ </script>
<script src="app.js"></script> /* 外部腳本,建議放 body 末尾或加 defer/async */
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5)"> /* 淡入 */
<meta http-equiv="Page-Exit" content="revealTrans(Duration=1.0, Transition=12)"> /* 轉場 */
現代改用 CSS @keyframes + view-transition API 實現跨瀏覽器轉場。
<meta http-equiv="Window-Target" content="_top">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
現代建議提供多尺寸 PNG + ICO 回退,並設定 manifest.json 統一管理 PWA 圖示。