HTML | <link> Tag

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


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : Akanksha_Rai

Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.