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 css file stylenew.css

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

This will produce the following result −

Global Attributes

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

Specific Attributes

The HTML <link> tag also supports the following additional attributes −

Attribute Value Description
charset charset Defines the character encoding of the linked document.
href URL Specifies the URL of the resource document.
hreflang language Language code of the destination URL
media screen
tty
tv
projection
handheld
print
braille
aural
all
Specifies the device the document will be displayed on
rel alternate
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-5 HeightxWidth Specifies the size of the linked resource.
target blank
_self
_top
_parent
Specifies the target frame to load the page into.
type mimetype The MIMEtype of content at the link destination

Event Attributes

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

Browser Support

Chrome Firefox IE Opera Safari Android
Yes Yes Yes Yes Yes Yes

html_tags_reference.htm

Advertisements