VOOZH about

URL: https://www.geeksforgeeks.org/html/html-link-tag/

⇱ HTML <link> Tag - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML <link> Tag

Last Updated : 12 Jul, 2025

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.

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.

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:

Comment
Article Tags: