Tag <tautan> HTML
Contoh
Tautan ke lembar gaya eksternal:
<head>
<link rel="stylesheet" href="styles.css">
</head>
Definisi dan Penggunaan
Tag <link>
mendefinisikan hubungan antara dokumen saat ini dan sumber daya eksternal.
Tag <link>
paling sering digunakan untuk menautkan ke lembar gaya eksternal atau untuk menambahkan favicon ke situs web Anda.
Elemen <link>
adalah elemen kosong, hanya berisi atribut.
Dukungan Peramban
Element | |||||
---|---|---|---|---|---|
<link> | Yes | Yes | Yes | Yes | Yes |
Atribut
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 |
Atribut Global
Tag <link>
juga mendukung Atribut Global dalam HTML .
Atribut Acara
Tag <link>
juga mendukung Atribut Peristiwa dalam HTML .
Halaman Terkait
Tutorial HTML: Gaya HTML
Referensi DOM HTML: Objek Tautan
Pengaturan CSS Default
Sebagian besar browser akan menampilkan <link>
elemen dengan nilai default berikut:
link {
display: none;
}