HTML Link


In HTML, the <link> element is used to create a link between a document and an external resource. The link tag is most commonly used to refer to external style sheets. This element can exist numerous times, but it should only appear in the head section. The link element is empty and solely includes attributes. The link element's values indicate how the item being linked to is related to the containing content.

Syntax

Example

Preview

Attributes

Attribute Description
charset This parameter specifies the character encoding for the HTML linked document.
crossorigin It assigns the linked document's CORS settings.
disabled It is used to indicate that the referenced document is inactive.
href It specifies the URL of the linked document.
hreflang It specifies the language of a linked document.
media It specifies what media/device the target resource is optimised for.
rel It specifies the relationship between the current and linked documents.
rev It applies the linked document's reverse connection to the current document.
sizes It is used to indicate the icon sizes for visual media and only works when rel="icon" is used.
target This specifies the window or frame in which the referenced page is loaded.
type It is used to set/return the referenced document's content type.

Example

Preview

HTML <link> target

The HTML <link> target Attribute specifies the window or frame in which the linked content is loaded. HTML 5 does not support it.

Syntax

Example

Preview

Attributes

Attribute Description
_blank It opens the link in a new window.
_self It is the default setting. The connected document is opened in the same frame.
_parent The connected document is opened in the parent frameset.
_top It displays the referenced document in the window's full body.
framename It displays the linked document in the specified frame.

FAQs

The <link> tag is used for linking external resources, not creating hyperlinks. To create a hyperlink, use the <a> tag.

The <link> tag is used to link external resources, not to style individual elements. To change the color of a link, use CSS.

The <link> tag is used to link external resources, not to control how links are opened. To open a link in a new window, use the target="_blank" attribute with the <a> tag.