HTML <link /> tagS2C Home   « HTML <link /> tag

Definition

The <link /> tag is a self closing tag that allows us to link to an external resource such as an image or stylesheet from within a HTML file.

The <link /> tag must reside within the <head></head> element.

Example


<html  xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>A Title which will appear in the Windows title bar.</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

  <link href="../global.css" rel="stylesheet" type="text/css" />

</head>
<body>
</body>
</html>

Required Attributes

NONE

Optional Attributes

rev - no browser support - specifies the relationship of the linked document to the current page.

target - limited browser support - specifies where to open the target.

charset specifies the character set of the linked document.


<link href="http://server2client.com/images/chickenpiesmall.jpg"
   charset="ISO-8859-1" /> 

href specifies the target URL to link to.


<link href="http://server2client.com/images/chickenpiesmall.jpg" />

hreflang specifies the language of target URL to link to.


<link href="http://server2client.com/images/chickenpiesmall.jpg"
   hreflang="en" /> 

media specifies a media with which the link is associated with.


<!-- media values supported in all browsers are (all, print, and screen) -->]

<!-- Other possible values are (aural, braille, handheld, projection tty and tv) -->
<link href="http://server2client.com/images/chickenpiesmall.jpg"
   media="print" /> 

rel specifies the relationship of the linked document to the current page.


<!-- The only rel type supported in all browsers is the stylesheet relationship -->

<!-- Other possible values which do not have universal browser support are: -->

<!-- (alternate, appendix, bookmark, chapter, contents, copyright, help,  -->
<!--  glossary, index, next, prev, section, start and subsection) -->

<link href="http://server2client.com/images/chickenpiesmall.jpg"
   rel="stylesheet" /> 

type specifies the MIME type of the linked document.



<link href="http://server2client.com/images/chickenpiesmall.jpg"
   type="text/css" /> 

Common Attributes

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<link class="classname" />

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<link id="idname" />

style - specifies an inline style for the element allowing you to apply the style to the content.


<link style="color:red;text-align:left" />

title - specifies extra information about the content.


<link title="information about the content" />

Language Attributes

dir - specifies the directional flow of the content.


<link dir="ltr" />   <!-- The text will flow from left to right -->
<link dir="rtl" />   <!-- The text will flow from right to left -->

lang - specifies a language code for the content of the element.


<link lang="en" />

xml:lang - specifies a language code for the content of the element in XHTML documents.


<link xml:lang="fr" />

Event Attributes

NONE

Although the <link /> tag supports mouse and key events the <link /> tag is situated within the <head></head> element. This element isn't visible within a HTML document so although these events are allowed they seem to serve no purpose within the <link /> tag.

go to home page Homepage go to top of page Top