HTML <link> Tag

Advertisements


Description

The HTML <link> tag is used for defining a link to an external document. It is placed in the <head> section of the document.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML link Tag</title>
<link rel="stylesheet" href="stylenew.css">
</head>
<body>
<div id="contentinfo">
<p>Welcome to our website. We provide tutorials on various subjects.</p>
</div>
</body>
</html>

Here is the csss file stylenew.css

#contentinfo p {
    line-height: 20px;
	margin: 30px;
	padding-bottom: 20px;
	text-align: justify;
	width: 140px;
	color: red;
}

This will produce following result:

Global Attributes

This tag supports all the global attributes described in - HTML Attribute Reference

Specific Attributes

The HTML <link> tag also supports following additional attributes:

AttributeValueDescription
charset charsetDefines the character encoding of the linked document.
hrefURLSpecifies the URL of the resource document.
hreflang languageLanguage code of the destination URL
mediascreen
tty
tv
projection
handheld
print
braille
aural
all
Specifies the device the document will be displayed on
relalternate
appendix
bookmark
chapter
contents
copyright
glossary
help
home
index
next
prev
section
start
stylesheet
subsection
Describes the relationship between the current document and the destination URL.
rev alternate
appendix
bookmark
chapter
contents
copyright
glossary
help
home
index
next
prev
section
start
stylesheet
subsection
Describes a reverse between the destination URI and the current document.
sizes html-5HeightxWidthSpecifies the size of the linked resource.
target blank
_self
_top
_parent
Specifies the target frame to load the page into.
type mimetypeThe MIMEtype of content at the link destination

Event Attributes

This tag supports all the event attributes described in - HTML Events Reference

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

html_tags_reference.htm