Breaking

Thursday, May 9, 2019

HTML link Tag


Example

Link to an external style sheet:
<head>
  <link rel="stylesheet"type="text/css" href="theme.css">
</head>
Try it Yourself »

Definition and Usage

The <link> tag defines a link between a document and an external resource.
The <link> tag is used to link to external style sheets.

Browser Support

When used for style sheets, the <link> tag is supported in all major browsers. No real support for anything else.
Element
<link>YesYesYesYesYes

Note: The <link> element is an empty element, it contains attributes only.
Note: This element goes only in the head section, but it can appear any number of times.

Differences Between HTML 4.01 and HTML5

Some HTML 4.01 attributes are not supported in HTML5.
The "sizes" attribute is new in HTML5.

Differences Between HTML and XHTML

In HTML the <link> tag has no end tag.
In XHTML the <link> tag must be properly closed.


Attributes

= New in HTML5.
AttributeValueDescription
charsetchar_encodingNot supported in HTML5.
Specifies the character encoding of the linked document
crossoriginanonymous
use-credentials
Specifies how the element handles cross-origin requests
hrefURLSpecifies the location of the linked document
hreflanglanguage_codeSpecifies the language of the text in the linked document
mediamedia_querySpecifies on what device the linked document will be displayed
relalternate
author
dns-prefetch
help
icon
license
next
pingback
preconnect
prefetch
preload
prerender
prev
search
stylesheet
Required. Specifies the relationship between the current document and the linked document
revreversed relationshipNot supported in HTML5.
Specifies the relationship between the linked document and the current document
sizesHeightxWidthanySpecifies the size of the linked resource. Only for rel="icon"
target_blank
_self
_top
_parent
frame_name
Not supported in HTML5.
Specifies where the linked document is to be loaded
typemedia_typeSpecifies the media type of the linked document

Global Attributes

The <link> tag also supports the Global Attributes in HTML.

Event Attributes

The <link> tag also supports the Event Attributes in HTML.

Related Pages

HTML tutorial: HTML Styles
HTML DOM reference: Link Object

Default CSS Settings

Most browsers will display the <link> element with the following default values:
link {
  display: none;
}

No comments:

Post a Comment