แท็ก <a> ใน HTML
องค์ประกอบ <a> ใน HTML ใช้สำหรับลิงก์หน้าหนึ่งไปยังอีกหน้าหนึ่งด้วยไฮเปอร์ลิงก์ (hyperlink) ลิงก์ที่ยังไม่ได้เยี่ยมชมเป็นสีน้ำเงิน ลิงก์ที่เยี่ยมชมแล้วเป็นสีม่วง ในขณะที่ลิงก์ที่ใช้งานอยู่เป็นสีแดง ลิงก์ทั้งหมดปรากฏแบบนี้บนเบราว์เซอร์เว็บและมีขีดเส้นใต้ คุณสามารถลิงก์ไปยังเว็บเพจภายนอกหรือเพจท้องถิ่นได้
แอตทริบิวท์ต่อไปนี้:
| แอตทริบิวท์ | ค่า | คำอธิบาย |
|---|---|---|
| charset (deprecated) | character_encoding | กำหนดการเข้ารหัสตัวอักษรของเอกสารที่ลิงก์ |
| coords (deprecated) | if shape = "rect" then coords = "left, top, right, bottom" if shape = "circ" then coords = "centerx,centery,radius" if shape = "poly" then coords = "x1, y1, x2, y2,..,xn,yn" | ระบุพิกัดที่เหมาะสมกับแอตทริบิวท์ shape เพื่อกำหนดพื้นที่ของภาพสำหรับ image maps |
| download | filename | ดาวน์โหลดเป้าหมายเมื่อผู้ใช้คลิกที่ไฮเปอร์ลิงก์ |
| href | URL | ระบุ URL ของหน้าหรือชื่อแองคอร์ที่ลิงก์ไป |
| hreflang | language_code | รหัสภาษาของ URL ปลายทาง |
| media | media_query | ระบุสื่อที่เอกสารที่ลิงก์ถูกปรับให้เหมาะสม |
| name (deprecated) | section name | ทำเครื่องหมายพื้นที่ของหน้าที่ลิงก์กระโดดไป |
| rel | alternate, designates, stylesheet, start, next, prev, contents, index, glossary, copyright, chapter, section, subsection, appendix, help, bookmark | อธิบายความสัมพันธ์ระหว่างเอกสารปัจจุบันและ URI ปลายทาง |
| rev (deprecated) | alternate, designates, stylesheet, start, next, prev, contents, index, glossary, copyright, chapter, section, subsection, appendix, help, bookmark | ระบุความสัมพันธ์ระหว่าง URL เป้าหมายและเอกสารปัจจุบัน |
| shape (deprecated) | rect, rectangle, circ, circle, poly, polygon | ระบุรูปร่างของ image map |
| target | _blank, _parent, _self, _top | ที่จะเปิด URL เป้าหมาย _blank - URL เป้าหมายจะเปิดในหน้าต่างใหม่ _self - URL เป้าหมายจะเปิดในเฟรมเดียวกับที่คลิก _parent - URL เป้าหมายจะเปิดใน frameset พาเรนต์ _top - URL เป้าหมายจะเปิดในทั้ง body ของหน้าต่าง |
| type | mime_type | ระบุประเภท MIME (Multipurpose Internet Mail Extensions) ของ URL เป้าหมาย |
ตัวอย่าง
<!DOCTYPE html>
<html>
<body>
<h2>Coding Ground</h2>
<h3>คอมไพเลอร์สำหรับภาษาโปรแกรมมิ่งและเทคโนโลยีเว็บ</h3>
<nav>
<a href="/compile_java_online.php">Java</a> |
<a href="/php_terminal_online.php">PHP</a> |
<a href="/online_jquery_editor.php">jQuery</a> |
<a href="/compile_c_online.php">C</a> |
<a href="/compile_cpp_online.php">C++</a> |
<a href="/online_angularjs_editor.php">AngularJS</a>
</nav>
</body>
</html>
ผลลัพธ์
