HTML <link> tag

HTML <link> tag

The <link> tag defines a relationship between an HTML document and an external resources (CSS stylesheets).

Example

HTML Online Editor
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <h1>This is a Heading.</h1> <p>This is a Paragraph.</p> </body> </html>

Attributes

The following are the attributes of <link> tag. Also try Global attributes.

AttributeValueExplanation
as
  • document
  • font
  • image
  • script
  • style
  • ...(etc)
Specifies the type of content being loaded by the <link> element.
It works only with rel="preload".
crossorigin
  • anonymous
  • use-credentials
Specifies whether CORS must be used when fetching the resource.
hrefURLSpecifies the URL of the linked resource.
hreflanglanguage_codeSpecifies the language of the linked resource.
integrityvalueSpecifies the fetched resource has been delivered free of unexpected manipulation.
mediamedia_querySpecifies on what device the linked resource will be displayed.
referrerpolicy
  • no-referrer
  • no-referrer-when-downgrade
  • origin
  • origin-when-cross-origin
  • unsafe-url
Specifies whether or not to sent http referrer information.
rel
  • alternate
  • author
  • dns-prefetch
  • help
  • icon
  • license
  • next
  • pingback
  • preconnect
  • prefetch
  • preload
  • prerender
  • prev
  • search
  • stylesheet
Specifies the relationship between the current document and the linked document.
sizes
  • Height x Width
  • any
Specifies the size of the linked resource. Works only with rel="icon".
titletextSpecifies the name of the style which is shown in the browser's menubar.
typemedia_typeSpecifies the media type of the linked resource.

Deprecated Attributes

The following attributes should not be used in any case.

AttributeValueExplanation
charsetcharacter_encodingSpecifies the character encoding of the linked document.
revtextSpecifies the relationship between the linked document and the current document.
target
  • _blank
  • _self
  • _top
  • _parent
  • frame_type
Specifies where the linked document should be opened.

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author