Absolute URL ใช้สำหรับลิงก์ไปยังเว็บไซต์ภายนอก (External Links) ต้องระบุโปรโตคอลและ domain เต็ม
รูปแบบ Absolute URL
https://www.example.com/page.html https://subdomain.example.com/path mailto:user@example.com tel:+66812345678
Attribute ของ <a> tag
| Attribute | คำอธิบาย |
|---|---|
href | URL ปลายทางเต็ม (จำเป็น) |
rel | ความสัมพันธ์: nofollow, external, author, bookmark |
target | เป้าหมาย: _blank (แนะนำสำหรับ external), _self |
title | Tooltip เมื่อ hover |
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<title>HTML Absolute links</title>
</head>
<body>
<h1>Qries</h1>
<p>
With <a href="https://www.qries.com/questions.php" target="_blank" rel="noopener noreferrer">Qries</a>,
get information about different topics such as games, government, education, geology, sports, etc.
</p>
</body>
</html>
แนวทางปฏิบัติที่ดีสำหรับ External Links
<a href="https://example.com" target="_blank" rel="noopener noreferrer external nofollow" title="Visit Example.com (opens in new tab)" > Example.com </a>
ข้อควรทราบ
- Absolute URL จำเป็นสำหรับ external links
- Relative URL ไม่ทำงานสำหรับ cross-domain
- Protocol-relative URL (
//example.com) deprecated แล้ว ควรระบุ https:// เสมอ