Versión en español




HTML link tag


Note: If you don't know what a tag is and/or how you must use it we recommend you to read our HTML tags and attributes tutorial that you can find in our HTML tutorials section.

Description

The HTML link tag works like the HTML a tag, but it's defined only in the head section of the document, and is used mostly to give relational information about it. For example, you can use the HTML link tag to say where in a chapter is this document located, or which document works as an index for it, or to specify alternate versions that are written in other languages or for other media.

Example:

Code begin <head>
<title>Chapter two</title>
<link rel="index" href="../index.html" />
<link rel="prev" href="chapter1.html" />
<link rel="next" href="chapter3.html" />
<link rel="alternate" media="print" href="chapter2-printer.html" />
<link rel="alternate" hreflang="es" href="chapter2-es.html" />
</head>
...Document's body...Code end


The HTML link tag is commonly used to point to external style sheet files:

Code begin <link type="text/css" href="basic.css" media="screen" />Code end



Attributes

id (name)

The "id" attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element.

Example:

Code begin <p id="paragraph1">This is the first paragraph named as paragraph1. To dynamically change its properties use this identifier.</p>Code end


class (cdata)

The "class" attribute assigns a class name (or a list of class names separated by spaces) to the container element. It's used with style sheets and tells the browser the class to which the element is associated with. A class gives visual attributes to elements.

Example:

Code begin <p class="references">This article is based on the book "Wind in the trees" by Jhon L. Brooks</p>

<p class="references important">This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.</p>Code end


style (style)

Defines a visual style of this element. Is a better practice to define styles attributes in external style sheets grouping them in classes. Attributes in the "style" parameter must preserve this order "name : value" and be separated by a semi-colon.

If you're writing XHTML code it's recommended not to use this attribute and try style sheet classes (with the "class" attribute).

Example:

Code begin <p style="color: #0000FF; font-size: 12pt">This is a paragraph with a defined style</p>
<p>And this is another text without style.</p>Code end


title (text)

Indicates a title for the element. Used to give a short description about the element that is usually shown as a "tool tip" when the user put the mouse pointer over the element.

Example:

Code View
<a title="HTMLQuick.com" href="https://www.htmlquick.com">HTML code</a> HTML code

lang (langcode)

Specifies the language of an element's content. The default value in "unknown".

When writing XHTML code the syntax "xml:lang" represents a preferred alternative in XHTML 1.0 and a replacement in XHTML 1.1 (e.g., xml:lang="en").

Example:

Code begin <p lang="en">This is a paragraph in english.</p>
<p lang="es">Este es un p&aacute;rrafo en espa&ntilde;ol.</p>Code end


dir

Specifies the text direction of the element's contents and attribute values, as well as tables directionality. It has two possible values that are case insensitive:
Example:

Code begin <q lang="he" dir="rtl">...a Hebrew quotation...</q>Code end


href (uri)

Specifies the destination resource for the element. Commonly used to refer to pages in the same domain name or external pages.

Example:

Code View
Link to page on this site: <a href="https://www.htmlquick.com/tutorials/links.html">Links in HTML tutorial</a><br />
Link to external site: <a href="https://www.w3.org">World Wide Web Consortium</a>
Link to page on this site: Links in HTML tutorial
Link to external site: World Wide Web Consortium

hreflang (langcode)

Defines the destination resources' language. This attribute may only be used when the "href" attribute is present.

Example:

Code begin <a hreflang="en" href="english-version.html">English version</a>Code end


type (content-type)

Tells the browser the content type of the resource named in "href" attribute.

Example:

Code begin <a href="logo.gif" type="image/gif">Check out our logo</a><br />
<a href="article.html" type="text/html">Read the article</a>Code end


rel (link-types)

Describes de relationship from the current document to the destination resource. In other words defines the meaning of the referred resource for the actual document.

Example:

Code begin <a rel="prev" href="article1.html">Read previous article</a>
<a rel="next" href="article3.html">Read next article</a>
<a rel="copyright" href="copyright.html">Article copyrights</a>

<a rel="alternate" href="english-version.html" hreflang="en">English version</a>Code end


rev (link-types)

Stablish a relationship from the resource pointed by the "href" attribute to the current document. In other words, establishes what represents the actual document for the referred resource.

Example:

Code begin List of articles:
<a rev="index" href="article1.html">Article 1</a>
<a rev="index" href="article2.html">Article 2</a>
...Code end


target (frame-target)

Specifies the name of the frame where the destination document should be loaded. Refer to the frame-target type definition for further information.

Code begin Open in a new window: <a href="https://www.w3c.org" target="_blank">WWW Consortium</a>
Open in a frame named "content" (frame must be present in the actual frameset): <a href="https://www.w3c.org" target="content">WWW Consortium</a>Code end


media (media-descriptor)

Specifies the media for which the destination document's been designed. It may be a single media or a comma-separated list of them. The default value is "screen".

Example:

Code begin <link rel="alternate" media="print" href="printer-version.html" />Code end


charset (charset)

Specifies the character encoding of the target URL. Refer to the type definition and the reference for character encoding for more information.

Example:

Code begin <a charset="utf-8" href="https://www.htmlquick.com">HTML code</a>Code end



Events

See complete list and information about events in HTML




Bypass footer options  |   Send to a friend Send to a friend  |  Post to del.icio.us Post to del.icio.us

Digg this page Digg this!  |  File on Furl File on Furl  |  Add to Yahoo! MyWeb Add to Yahoo! MyWeb

Bypass W3C declarations | 

Valid XHTML 1.0 Strict  |  Valid CSS Why should you trust us? Click the images on the left to see how seriously we write our own pages, then make your choice.

Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0. This website gives its best effort to achieve the Level Triple-A Conformance, W3C-WAI Web Content Accessibility Guidelines 1.0. If you find any detail or error that we didn't see, don't hesitate and let us know.

The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. -- Tim Berners-Lee, W3C Director and inventor of the World Wide Web.

 Link to us  |  Contact us  |  Beyond HTML  |  Tools and resources  |  Sitemap  |  Webmaster