Published Jun 9, 2022Updated Jul 1, 2022
Contribute to Docs

The <link> element connects the current web page with an external file such as a stylesheet or a library.


<title>Links in HTML</title>
<link rel="stylesheet" href="some/outside/source.css" />

The two primary attributes are:

  • A rel to describe the format of the external source.
  • An href that contains the filepath to the external source.

It is best practice that the <link> element is always defined inside the <head> element.


The following example shows how the <link> element can also be used to make icons for the page, including Apple PWA home screen icons:

<!DOCTYPE html>
<html lang="en">
<title>Links in HTML</title>
<link rel="stylesheet" href="some/outside/source.css" />
<link rel="icon" href="favicon.ico" />
<!-- After iOS 7-->
<link rel="apple-touch-icon" href="apple-icon-114.png" type="image/png" />
<!-- iOS 7 and before -->
<!-- markup here -->

All contributors

Looking to contribute?

Learn HTML on Codecademy