Znacznik HTML <link>


Przykład

Link do zewnętrznego arkusza stylów:

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

Definicja i użycie

Tag <link>definiuje relację między bieżącym dokumentem a zasobem zewnętrznym.

Tag <link>jest najczęściej używany do tworzenia linków do zewnętrznych arkuszy stylów lub dodawania favikony do Twojej witryny.

Element <link>jest pustym elementem, zawiera tylko atrybuty.


Obsługa przeglądarki

Element
<link> Yes Yes Yes Yes Yes


Atrybuty

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

Atrybuty globalne

Znacznik <link>obsługuje również atrybuty globalne w HTML .


Atrybuty wydarzenia

Tag <link>obsługuje również Atrybuty Zdarzeń w HTML .


Powiązane strony

Samouczek HTML: Style HTML

Odniesienie HTML DOM: Obiekt łącza


Domyślne ustawienia CSS

Większość przeglądarek wyświetla <link>element z następującymi wartościami domyślnymi:

link {
  display: none;
}