HTML link element

<link> tag links the current document to the other resources. These resources may be CSS sytylesheet or javascript file.


<!DOCTYPE html>
  <link rel="stylesheet" href="files/test.css" />
  <p>The style sheet given above gives style to the div element</p>
  <p>Here "rel" attribute stands for "relation". And the attribute of rel is a stylesheet of css.</p>
  <div class="style"><p> This is block of content and the style sheet test.css designs the this block.</p></div>
Try </>

We write the URL or address of the external document in the href attribute of link element. link element is usually written inside head element.

Global Attributes

All the global attributes are applicable on the link element.

Tag omission

It is a self-closing tag (<link />) i.e. there is no end tag.

Specific Attributes

The following attributes are related to the link element.

<link> tag attributes

href The address of the linked resource.
<link href="address of external resource">
rel relation of the current document to the external document.
<link href="design.css" rel="stylesheet">
media Type of media to which the external resource applies.
<link href="design.css" media="print">
hreflang The language of the external document. It may be Js or CSS file.
<link href="design.css" hreflang="en">
type Tells about the type of external resource.
<link href="design.css" type="text/css">
sizes Sizes of the icons that appear in the tab bar.
<link href="" size="50x50">

Was this article helpful?




Get the newsletter