Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

แท็ก <a> ใน HTML


แท็ก <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
downloadfilenameดาวน์โหลดเป้าหมายเมื่อผู้ใช้คลิกที่ไฮเปอร์ลิงก์
hrefURLระบุ URL ของหน้าหรือชื่อแองคอร์ที่ลิงก์ไป
hreflanglanguage_codeรหัสภาษาของ URL ปลายทาง
mediamedia_queryระบุสื่อที่เอกสารที่ลิงก์ถูกปรับให้เหมาะสม
name (deprecated)section nameทำเครื่องหมายพื้นที่ของหน้าที่ลิงก์กระโดดไป
relalternate, 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 ของหน้าต่าง
typemime_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>

ผลลัพธ์

แท็ก <a> ใน HTML