<a href="URL" target="_blank" rel="noopener noreferrer" hreflang="zh-Hant" download="filename.pdf">連結文字</a>
| 屬性 | 說明 | 常用值 |
|---|---|---|
| href | 目標 URL (必填) | 絕對/相對/錨點/mailto/tel/javascript/data URI |
| target | 開啟位置 | _blank(新分頁)、_self(預設)、_parent、_top、iframe名稱 |
| rel | 關係/安全 | noopener(斷開 opener)、noreferrer(不送 Referer)、nofollow(SEO)、preload、prefetch |
| hreflang | 目標語言 | zh-Hant、en-US、ja 等 BCP 47 標籤 |
| download | 強制下載並指定檔名 | 僅同源生效 |
| ping | 點擊時送 POST 到 URL 列表 (追蹤) | 空格分隔多 URL |
| referrerpolicy | Referer 政策 | no-referrer、origin、strict-origin-when-cross-origin 等 |
<img src="floorplan.png" usemap="#rooms" alt="樓層平面圖">
<map name="rooms">
<area shape="rect" coords="10,10,100,80" href="/room/101" alt="會議室 101">
<area shape="circle" coords="200,150,30" href="/room/201" alt="休息區">
<area shape="poly" coords="300,50,350,100,250,100" href="/room/301" alt="經理室">
<area shape="default" href="/directory" alt="其他區域">
</map>
shape:rect(x1,y1,x2,y2)、circle(cx,cy,r)、poly(x1,y1,x2,y2...)、default(剩餘區域)。
<link rel="stylesheet" href="main.css">
<link rel="preload" href="critical.woff2" as="font" type="font/woff2" crossorigin>
<link rel="prefetch" href="next-page.html">
<link rel="preconnect" href="https://cdn.example.com">
<link rel="dns-prefetch" href="//api.example.com">
<link rel="canonical" href="https://example.com/canonical-url">
preload:當前頁必須、高優先級資源 (字體、關鍵 CSS/JS)。prefetch:未來頁面可能用到的資源 (低優先級)。preconnect:提前建立 TCP/TLS 連線 (跨域關鍵域名)。canonical:告訴搜尋引擎標準網址,避免重複內容。<head>
<base href="https://example.com/app/" target="_blank">
</head>
<body>
<a href="page.html">實際解析為 https://example.com/app/page.html</a>
</body>
全文檔僅能出現一個,置於 <head> 內,影響所有相對連結 (含 <img src>、<script src>、<link href>)。
target="_blank" 必加 rel="noopener noreferrer",防止 window.opener 被惡意導向。javascript:、data:、vbscript: 等危險協議;前端二次檢查。encodeURIComponent() 處理動態參數。navigate-to、form-action 導向範圍。aria-label / aria-labelledby 補充隱藏連結文字。:focus-visible)。