Skip to content
Related Articles

Related Articles

HTML | <link> Tag
  • Last Updated : 04 Nov, 2019

The link tag is used to define a link between a document and an external resource. The link tag is used to link to external style sheets. This element can appear multiple times but it goes only in the head section.
The link element is empty, it contains attributes only.

Syntax:

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

Attributes:

Value Description
charset It assigns the character encoding of the linked document
crossOrigin It assigns the CORS settings of the linked document
disabled It assigns whether the linked document is disabled, or not
href It is used to set/return the URL of the linked document
hreflang It assigns the language code of the linked document
media It assigns the media type for the link element
rel It assigns the relationship between the current document and the linked document
rev It assigns the reverse relationship from the linked document to the current document
sizes Returns the sizes attribute’s value of the linked resource
type It is used to set/return the content type of the linked document

Example: HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>HTML Link Tag</title>
    <link rel="stylesheet"
          type="text/css"
          href="styles.css">
</head>
  
<body>
  
    <h1>GeeksforGeeks</h1>
    <h2>HTML Link Tag</h2>
  
</body>
  
</html>

chevron_right


CSS:



filter_none

edit
close

play_arrow

link
brightness_4
code

h1 {
    color: green;
}
  
h1, h2{
    text-align: center;
}

chevron_right


Output:

Supported Browsers: The browsers supported by HTML <link> Tag are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :