Other uses of the link tag

5

Apart from the traditional use of cascading style sheets:

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

Is there any other use of the <link> element that is useful in a web page? Does the HTML5 standard give any light about it?

    
asked by dwarandae 26.02.2016 в 04:08
source

2 answers

4

Although as you say, link is mainly used for CSS style sheets, it also allows linking other types of information, depending on the value of the rel attribute. How the browser interprets it will vary according to the type of resource it is (in some cases it will be shown, in others it will be treated as meta-data).

For example, link allows linking:

  • Author information: author . I include the following code to associate the page with my Google+ profile (yes, I must be the only one that uses it: P):

    <link rel="author" href="https://plus.google.com/118137220962857817327" />
    
  • Page icon: icon or shortcut icon . Makes the browser display the icon next to the page title (in the window or tab):

    <link rel="shortcut icon" href="https://url.a.mi/fav.ico" />
    
  • Help information: help . To link a page that will provide additional help on the page:

    <link rel="help" href="https://es.wikipedia.org/wiki/articulo-relacionado" />
    
  • The next page in a sequence: next . If you are on a page that follows an order (for example, a tutorial), you can indicate which page should be the next one. A real example taken from the NumPy website :

     <link rel="next" title="Numpy license" href="license.html" /> 
    
  • The previous page in a sequence: prev . Similar to the previous one, but instead of the next, point to the previous page:

     <link rel="prev" title="NumPy" href="index.html" /> 
    

You can find other examples of the types allowed in the MDN page .

    
answered by 26.02.2016 / 05:04
source
1

The Link tag has different types of use that are not only used to include a style sheet (CSS) in a web but it is true that by default it is used to "link" other files, documents, images, etc. .

For example:

To define the favicon of a web (Icon that can be seen in the browser tab, use the link tag in the following way:

<link rel="icon" type="img/ico" href="img/favicon.ico">

You can also use it to define the relationship between the pages and the course of the web. These are attributes that are not normally used but are endorsed and recommended by the w3c.

Example:

<link rel="previous" href="anterior.html" />
<link rel="next" href="proximo.html" />
<link rel="contents" href="../actual.html#toc" />

Another use that is usually given is to define a style but not for the web but for the printing of said web.

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

I leave a link where you can see a little more detailed use of the tag, among other things " Link ".

    
answered by 26.02.2016 в 04:22