HTML <リンク>タグ


外部スタイルシートへのリンク:

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

定義と使用法

<link>タグは、現在のドキュメントと外部リソースの間の関係を定義します

このタグは、外部のスタイルシートにリンクしたり、Webサイトにファビコン<link>を追加したりするために最もよく使用されます。

<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>タグは、HTMLのグローバル属性もサポートしています。


イベント属性

この<link>タグは、HTMLのイベント属性もサポートしています。


関連ページ

HTMLチュートリアル:HTMLスタイル

HTML DOMリファレンス:リンクオブジェクト


デフォルトのCSS設定

ほとんどのブラウザは<link>、次のデフォルト値で要素を表示します。

link {
  display: none;
}