Copyright © tutorialspoint.com

# HTML <link> tag

## Function:

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

## Difference between HTML and XHTML:

In HTML the <link> tag has no end tag.

In XHTML the <link> tag must be properly closed.

## Example:

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

## 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
type | mimetype | The MIMEtype of content at the link destination
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.
target | blank _self _top _parent | Specifies the target frame to load the page into.
media | screen tty tv projection handheld
print
braille
aural
all
Specifies the device the document will be displayed on

## Standard Attributes:

Attribute | Description
--- | ---
class | Document wide identifier
dir | Specifies the direction of the text
id | Document wide identifier
title | Specifies a title to associate with the element.
style | Helps to include inline casecadubf style sheet.
lang | Sets the language code.
xml:lang | Sets the language code.

## Event Attributes:

Attribute | Description
--- | ---
onclick | Script runs when a mouse click
ondblclick | Script runs when a mouse double-click
onmousedown | Script runs when mouse button is pressed
onmouseup | Script runs when mouse button is released
onmouseover | Script runs when mouse pointer moves over an element
onmousemove | Script runs when mouse pointer moves
onmouseout | Script runs when mouse pointer moves out of an element
onkeypress | Script runs when key is pressed and released
onkeydown | Script runs when key is pressed
onkeyup | Script runs when key is released

Copyright © tutorialspoint.com