HTML <link> href Attribute

The href attribute on a <link> tag specifies the URL of either a style sheet or icon. The href value can be an internal URL or an external URL.

Example

#

An href attribute on a <link> element.
This link loads a stylesheet which is then used to style a paragraph.

Styled using external css.

<link rel="stylesheet" href="/tutorial/style.css">

<p class="aliceblue">Styled using external css.</p>

Here is the content of the stylesheet:

.aliceblue { background-color: aliceblue; color: steelblue; padding: 10px; }
.papaya { background-color: papayawhip; color: indianred; padding: 10px; }

Using link

The href attribute specifies the URL or path of the stylesheet or site icon.

This attribute on a <link> will load the specified stylesheet or site icon.

It accepts any of these URLs:

  • absolute URL - links to an external website or domain (e.g. https://wikipedia.com)
  • relative URL - links to a resource on the same website or domain (with a shorter url)

Syntax

<link href="URL" />

Values

#

Value Description
URL URL or path of the stylesheet or icon.

Browser support

Here is when href support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <link>
Guides