HTML <link>
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.
Syntax
<head><title>Links in HTML</title><link rel="stylesheet" href="some/outside/source.css" /></head>
The two primary attributes are:
- A
relto describe the format of the external source. - An
hrefthat contains the filepath to the external source.
It is best practice that the <link> element is always defined inside the <head> element.
Example
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"><head><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 --><linkrel="apple-touch-icon-precomposed"href="apple-icon-114.png"type="image/png"/></head><body><!-- markup here --></body></html>
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
- Beginner Friendly.7 hours