w3resource

HTML link tag and element

1. HTML link element defines relationship between two HTML documents.

2. It can be used only within head tags of an HTML document.

3. link element starts with <link> tag and it's end tag is forbidden.

Syntax

<link rel='value' href='link' type='type of content the linked document is containing' /> 

Whether both start and end tags are required

The start tag is required but end tag is forbidden.

Can contain

HTML link element is an empty element, i.e. it can not contain any other text or element.

Can reside within

HTML link element can reside within head element.

Attributes

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Events

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.

Image maps

shape and coords.

Target frame information

target.

Tabbing navigation

tabindex.

Access keys

accesskey.

Links and anchors

href, hreflang, type, rel, rev.

Header style information

media.

character encodings

charset.

Example of using HTML link element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML link tag example &gt; HTML tutorial | w3resource</title>
<link rel="stylesheet" type="text/css" href="link.css"> 
</head>
<body>
<ul>
<li>PHP Tutorial</li>
<li>JavaScript Tutorial</li>
<li>MySQL Tutorial</li>
</ul>
</body>
</html>

Result

html link element

View this example in a separate browser window

HTML link tag example.

Previous: HTML a tag and element
Next: HTML base tag and element