Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
HTML <link> Tag
Next article icon

HTML <link> Tag

Last Updated : 27 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The HTML <link> tag defines the relationship between the current document and an external resource, often for stylesheets or favicons. It's an empty element with attributes like href and rel.

Note: The <link> tag also supports the Global Attributes and  Event Attributes in HTML.

Syntax

 <link rel="stylesheet" href="styles.css">

Attributes values

Attribute ValueDescription
charsetSpecifies the character encoding for the HTML-linked document.
crossOriginAssign the CORS (Cross-Origin Resource Sharing) settings of the linked document.
disabledSpecifies that the linked document is disabled.
hrefSpecifies the URL of the linked document.
hreflangSpecifies the language for a linked document.
mediaSpecifies what media/device the target resource is optimized for.
relSpecifies the relationship between the current and the linked document.
revAssigns the reverse relationship from the linked document to the current document.
sizesSpecifies the sizes of the icon for visual media; works when rel="icon".
targetSpecifies the window or a frame where the linked document is loaded.
typeSets/returns the content type of the linked document.

HTML link Tag Examples

Example 1: Basic Implementation

This example demonstrates the use of the <link> tag to link an external stylesheet and the declaration of the rel and type attributes.

HTML
<!DOCTYPE html> <html>  <head>     <title>HTML Link Tag</title>     <link rel="stylesheet"            type="text/css"            href="style.css"> </head>  <body style="background-color:               green; color: green;">     <h1>GeeksforGeeks</h1>     <h3>HTML Link Tag</h3>     <p>         A Computer Science portal for geeks.         It contains well written, well thought         and well explained computer science and         programming articles.     </p> </body>  </html> 

 Output:

HTML <link> Tag

Example 2: Using hreflang Attribute

This example uses the hreflang attribute to specify the language of the linked document and links an external CSS file that styles <h1> tags.

HTML
<!DOCTYPE html> <html>  <head>     <title>HTML Link Tag</title>     <link rel="stylesheet"            type="text/css"           href="style.css"            hreflang="en-us"> </head>  <body>     <h1>GeeksforGeeks</h1>     <h2>HTML Link Tag</h2> </body>  </html> 
CSS
h1{     color: green; } 

Output:

HTML  link Tag with attributes
HTML link Tag with attributes

Supported Browsers

The browser supported by value attribute in option tag are listed below:

  • Google Chrome 5.0
  • Edge 12
  • Mozilla 4.0
  • Safari 5.0
  • Opera 11.1

Next Article
HTML <link> Tag

V

Vijay Sirra
Improve
Article Tags :
  • Web Technologies
  • HTML
  • HTML-Tags

Similar Reads

    HTML <ins> Tag
    HTML <ins> tag is used to specify a block of inserted text. The <ins> tag is typically used to mark a range of text that has been added to the document. The inserted text is rendered as underlined text by the web browsers although this property can be changed using the CSS text-decoratio
    3 min read
    HTML <i> Tag
    The <i> tag in HTML is used to display the content in italic style. This tag is generally used to display the technical term, phrase, the important word in a different language. The <i> tag is a container tag that contains the opening tag, content & closing tag.Syntax// Inline way to
    3 min read
    HTML <html> Tag
    HTML is a language full of diverse elements, and one such element is the <html> tag. This tag, standing for ‘HyperText Markup Language’, is used to define the root of an HTML or XHTML document.It serves as the main container for all other HTML elements, excluding the <!DOCTYPE> declarati
    3 min read
    HTML <nav> Tag
    The <nav> tag in HTML is used to define navigation sections on a webpage. It typically contains links to key parts of the site, such as the main menu, table of contents, or index. These links are usually organized using unordered lists (<ul>) or displayed as standalone links.Using the
    3 min read
    HTML | <link> target Attribute
    The HTML <link> target Attribute is used to specify the window or a frame where the linked document is loaded. It is not supported by HTML 5. Syntax: <link target="_blank|_self|_parent|_top|framename"> Attribute Values: _blank: It opens the link in a new window. _self: It is the default
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences