Code has been added to clipboard!

HTML link Tag

Reading time 2 min
Published Jun 29, 2017
Updated Oct 2, 2019
  • By using HTML link tag, you can set a link between a document and an external resource.
  • Unlike the <a> tag which is written in the <body> element, HTML link tag has to be placed in the <head>.
  • HTML link tag is typically used to link CSS to HTML for external stylesheets.
  • You don't need to use the ending tag.

Using the link tag, HTML document can be linked with an external resource:

Example
<link rel="stylesheet" type="text/css" href="style_file.css">

This tag is often used to link stylesheet to a document that needs to be styled. However, by including link tag, HTML icons can be established as well.

Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

The href attribute adds a path (URL) to the external document:

Example
<link rel="stylesheet" type="text/css" href="style_file.css">

hreflang sets the linked document's language:

Example
<link rel="stylesheet" type="text/css" hreflang="en" href="style_file.css">

Note: you can only use hreflang alongside href.

media defines what type of device the linked material is optimized for:

Example
<link rel="stylesheet" type="text/css" href="print.css" media="print">

rel defines the current document's and the linked document's relationship:

Example
<link rel="stylesheet" type="text/css" href="theme.css">

sizes sets the size for the icon in the linked resource:

Example
<link rel="icon" href="character.gif" type="image/gif" sizes="20x20">

Note: you can only use sizes when HTML rel has a value of an icon.

target specifies where the linked document is to be loaded:

Example
<link rel="parent" href="character.htm" target="_blank">

Note: usually this attribute is assigned for the linked page to load in another tab (not on the current page). The value needed in this case is _blank.

charset defined the linked document's character encoding:

Example
<link charset="UTF-8" href="file">

Tip: instead of charset, you can include a Content-Type HTTP header in the external file.

rev defined the linked document's and the current document's relationship:

Example
<link rev="parent" href="doggo.htm">

Tip: instead of rev, you can use HTML rel.

Browser support

Browser image
Chrome
1+
Browser image
Edge
All
Browser image
Firefox
1+
Browser image
IE
All
Browser image
Opera
All
Browser image
Safari
All

Mobile browser support

Browser image
Chrome
All
Browser image
Firefox
4+
Browser image
Opera
All
Browser image
Safari
All

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 28/01/2021
3176 People Used
Only 97 Left
Rating
5.0