HTML <link> Tag
Description
The HTML <link>
tag is used to establish relationships between the current web page and external resources, such as stylesheets, icons, or other documents. It is placed within the document's head section and primarily serves to define how the document should be presented or behave. For instance, you can use the <link>
tag to reference an external CSS (Cascading Style Sheet) file to apply styles to the webpage, or to link to a favicon for displaying a custom icon in the browser's tab. Additionally, the <link>
tag can be used to establish relationships with other documents like RSS feeds or alternate versions of the webpage for different languages or media types.
Properties
- Permitted Parents
- Any element that accepts metadata elements. If itemprop is present: any element that accepts phrasing content
- Content
- None. It is an empty element.
- Start/End Tags
- Start tag: required, End tag: forbidden
Example
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
Attributes
Attribute | Definition |
---|---|
href | Specifies the location of a Web resource, thus defining a link between the current element (the source anchor) and the destination anchor defined by this attribute. |
hreflang | Specifies the base language of the resource designated by href and may only be used when href is specified. |
type | The MIMEtype of content at the link destination |
rel | Describes the relationship between the current
document and the destination URI.
|
target |
Specifies the target frame to load the page into.
|
media | Specifies the device the document will be
displayed on. Possible values:
|
charset | Specifies the character encoding of the resource designated by the link. |
Global Attributes
The <link>
tag also supports the Global Attributes in HTML5
Event Attributes
The <link>
tag also supports the Event Attributes in HTML5
Browser Support
The following table will show you the current browser support for the HTML <link>
tag.
Desktop | |||||
12 | 1 | 1 | 12.1 | 4 |
Tablets / Mobile | |||||
18 | 4 | 12.1 | 3.2 | 1 | 4.4 |
Last updated by CSSPortal on: 30th March 2024