Hussain
Hussain

Reputation: 663

What does <link> tag do besides including stylesheets?

I know that the HTML <link> tag is used for attatching stylesheets, but looking at the W3CSchools tag reference, it has many other values for the rel attribute. I've looked all over the place, but I can't for the life of me find a place that describes in detail what the other values do and how they work. Can anyone send me to the right place or explain it themselves?

I know that the link tag supplies other pages that relate to the current document, but how are they used? For example, how are the first, prev, and next relationships used?

Upvotes: 14

Views: 3169

Answers (6)

Richard JP Le Guen
Richard JP Le Guen

Reputation: 28753

It links ;)

It's a way to say "this other resource and I (the HTML document) have a relationship."

The rel attribute says what the linked item is to the HTML document.

The rev attribute says what the HTML document is to the linked item.

So...

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

Says "style.css is the style sheet for this HTML document."

Silly analogy: If HTML documents could be 'married' (in highly conservative no-same-sex-marriages) we could do something like this:

<link rel="wife" rev="husband" href="otherFile.html" />

With this element, the HTML document is saying that "otherFile.html is my wife, and I am its husband."

Upvotes: 7

SLaks
SLaks

Reputation: 888185

In addition to all of the other answers, it's also used for RSS feeds.

For example: (From this very page)

<link rel="alternate" type="application/atom+xml" 
      title="Feed for question 'What does the HTML &lt;link&gt; tag do besides including stylesheets?'" 
      href="/feeds/question/2082362">

Upvotes: 5

Darryl Hein
Darryl Hein

Reputation: 145117

In addition to what Pekka said, I've seen it used for a pingback (rel="pingback") link, often used on blogs.

Upvotes: 1

Pekka
Pekka

Reputation: 449783

I know two prominent common uses:

  • With rel="stylesheet" to reference external CSS style sheets

  • With rel="favicon" to reference browser favicons

Additionally, there are

  • Forward and reverse links (rel="next")

  • Links to alternative resources for search engines (rel="alternate")

Check the W3C Reference: Links in HTML documents for details on stylesheet, and the latter two.

Upvotes: 8

Faqa
Faqa

Reputation: 544

Uh....

http://www.w3schools.com/TAGS/att_link_rel.asp

Basically, it's just a tag that says "other stuff needed for document is here", and the rel tag specifies exactly what that might be.

Upvotes: -1

Roger Pate
Roger Pate

Reputation:

The <link> tag conveys relationship information. For stylesheets, that means "here are instructions on how to display this file", but links are used for semantic references of many kinds, including others not listed in the HTML spec.

Upvotes: 2

Related Questions