ข้อมูลอ้างอิงHTML

HTML โดยตัวอักษร HTML ตามหมวดหมู่ รองรับ HTML Browser แอตทริบิวต์ HTML HTML Global Attributes เหตุการณ์ HTML HTML สี HTML Canvas HTML เสียง/วิดีโอ ชุดอักขระ HTML HTML Doctypes การเข้ารหัส URL HTML รหัสภาษา HTML รหัสประเทศ HTML ข้อความ HTTP วิธี HTTP ตัวแปลง PX เป็น EM แป้นพิมพ์ลัด


HTML <link>แท็ก


ตัวอย่าง

ลิงก์ไปยังสไตล์ชีตภายนอก:

<head>
  <link rel="stylesheet" href="styles.css">
</head>

ความหมายและการใช้งาน

แท็ ก<link>กำหนดความสัมพันธ์ระหว่างเอกสารปัจจุบันและทรัพยากรภายนอก

แท็ ก<link>นี้มักใช้เพื่อลิงก์ไปยังสไตล์ชีตภายนอกหรือเพื่อเพิ่มfaviconในเว็บไซต์ของคุณ

อิ ลิ<link>เมนต์เป็นอิลิเมนต์ว่าง มีเพียงแอททริบิวต์เท่านั้น


รองรับเบราว์เซอร์

Element
<link> Yes Yes Yes Yes Yes


คุณลักษณะ

Attribute Value Description
crossorigin anonymous
use-credentials
Specifies how the element handles cross-origin requests
href URL Specifies the location of the linked document
hreflang language_code Specifies the language of the text in the linked document
media media_query Specifies on what device the linked document will be displayed
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
unsafe-url
Specifies which referrer to use when fetching the resource
rel alternate
author
dns-prefetch
help
icon
license
next
pingback
preconnect
prefetch
preload
prerender
prev
search
stylesheet
Required. Specifies the relationship between the current document and the linked document
sizes HeightxWidth
any
Specifies the size of the linked resource. Only for rel="icon"
title   Defines a preferred or an alternate stylesheet
type media_type Specifies the media type of the linked document

คุณสมบัติสากล

แท็ ก<link>ยังสนับสนุน Global Attributes ในHTML


คุณสมบัติของเหตุการณ์

แท็ ก<link>ยังสนับสนุนแอตทริบิวต์เหตุการณ์ใน HTML


หน้าที่เกี่ยวข้อง

กวดวิชา HTML: สไตล์ HTML

การอ้างอิง HTML DOM: วัตถุลิงก์


การตั้งค่า CSS เริ่มต้น

เบราว์เซอร์ส่วนใหญ่จะแสดง<link>องค์ประกอบด้วยค่าเริ่มต้นดังต่อไปนี้:

link {
  display: none;
}