Skip to content
Related Articles

Related Articles

Improve Article

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:

ValueDescription
charsetIt assigns the character encoding of the linked document
crossOriginIt assigns the CORS settings of the linked document
disabledIt assigns whether the linked document is disabled, or not
hrefIt is used to set/return the URL of the linked document
hreflangIt assigns the language code of the linked document
mediaIt assigns the media type for the link element
relIt assigns the relationship between the current document and the linked document
revIt assigns the reverse relationship from the linked document to the current document
sizesReturns the sizes attribute’s value of the linked resource
typeIt is used to set/return the content type of the linked document

Example: HTML




<!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>

CSS:






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

Output:

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

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

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :