rel-alternate: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
(drafted to explain and provide examples of how rel-alternate is quite the special rel value, not that independent, and combines with other rel values and attributes to do special things)
 
(linking to hreflang)
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{stub}}
{{stub}}


== special combinations ==
== Special Combinations ==
While rel="alternate" does by itself mean that the destination is some alternate representation or version of the current page, it combines in special ways with other rel values and other attributes to provide different more specific meanings, in particular:
While <code>rel="alternate"</code> does by itself mean that the destination is some alternate representation or version of the current page, it combines in special ways with other <code>rel</code> values and other attributes to provide different more specific meanings, in particular:


=== with rel stylesheet ===
=== With <code>rel stylesheet</code> ===
==== alternate style sheets ====
==== Alternate stylesheets ====
<code>rel="alternate stylesheet"</code> is [http://www.w3.org/TR/html4/present/styles.html#h-14.3.1 how you provide an alternate style sheet] for the document, and note that the style sheet is NOT an alternate representation of the current page.
<code>rel="alternate stylesheet"</code> is [http://www.w3.org/TR/html4/present/styles.html#h-14.3.1 how you provide an alternate stylesheet] for the document. Note that the stylesheet is ''not'' an alternate representation of the current page.


=== with hreflang ===
=== With <code>hreflang</code> ===
==== alternate language versions ====
==== Alternate language versions ====
when present with an explicit <code>hreflang</code> attribute (with a value other than that of the document itself), rel="alternate" means a link to a version of the current document but in the language indicated by the hreflang attribute.
When used in combination with the <code>hreflang</code> attribute (with a value other than that of the document itself), <code>rel="alternate"</code> means a link to a version of the current document, but in the language indicated by the <code>hreflang</code> attribute.


Example from http://gmpg.org/xfn/creator :
Example from http://gmpg.org/xfn/creator :
Line 17: Line 17:
</source>
</source>


=== with media ===
See also: [http://support.google.com/webmasters/bin/answer.py?hl=en&answer=189077 Google Webmaster Tools Help: rel="alternate" hreflang="x"] and [[hreflang]]
==== alternate devices and media ====
when present with an explicit <code>media</code> attribute, rel="alternate" means a link to a version of the current document especially for the specified device or medium indicated by the media attribute.


Example, linking to a mobile version of a site:
=== With <code>media</code> ===
<source lang=html4strict>
==== Alternate devices and media ====
When used in combination with the <code>media</code> attribute, <code>rel="alternate"</code> means a link to a version of the current document, especially for the specified device or medium indicated by the <code>media</code> attribute.
 
For example, this is one possible way of linking to a site's mobile version:
<source lang="html4strict">
<a href="http://m.twitter.com" rel="alternate" media="handheld">Twitter mobile site</a>
<a href="http://m.twitter.com" rel="alternate" media="handheld">Twitter mobile site</a>
</source>
</source>


=== with type ===
=== With <code>type</code> ===
==== feed for the page ====
==== Page Feed ====
when present with an explicit <code>type</code> attribute (with a value other than that of the document itself, e.g. other than "text/html"), rel="alternate" means a link to a representation of the contents of the current document in a different format as designated by the type attribute.
 
When used in combination with the <code>type</code> attribute (with a value other than that of the document itself; e.g. other than <code>"text/html"</code>), <code>rel="alternate"</code> means a link to a representation of the contents of the current document in a different format, as designated by the <code>type</code> attribute.


Examples:
Examples:
<source lang=html4strict>
 
<source lang="html4strict">
<link rel="alternate" type="application/rss+xml" href=".rss"
<link rel="alternate" type="application/rss+xml" href=".rss"
       title="RSS feed for this page"/>
       title="RSS feed for this page"/>
Line 40: Line 44:
</source>
</source>


=== with type and rel home ===
=== With <code>type</code> and <code>rel home</code> ===
==== feed for the site of this page ====
==== Site Feed ====
{{main|rel-home#use_with_rel-alternate}}
{{main|rel-home#use_with_rel-alternate}}


Proposed: when present with an explicit <code>type</code> attribute (with a value other than that of the document itself, e.g. other than "text/html"), rel="alternate home" means a link to a representation of the contents of the ''site'' (the home page for the current page) in a different format as designated by the type attribute.
'''Proposed:'''
When used in combination with the <code>type</code> attribute (with a value other than that of the document itself, e.g. other than <code>"text/html"</code>), <code>rel="alternate home"</code> means a link to a representation of the contents of the ''site'' (the home page for the current page) in a different format, as designated by the <code>type</code> attribute.


Examples:
Examples:
<source lang=html4strict>
 
<source lang="html4strict">
<link rel="alternate home" type="application/rss+xml" href=".rss"
<link rel="alternate home" type="application/rss+xml" href=".rss"
       title="RSS feed for this site"/>
       title="RSS feed for this site"/>
Line 56: Line 62:
</source>
</source>


== see also ==
== See Also ==
* [[existing-rel-values]]
* [[existing-rel-values]]
* [[rel-faq]]
* [[rel-faq]]
* [[rel-home]], in particular [[rel-home#use_with_rel-alternate|rel-home with rel-alternate proposal]]
* [[rel-home]], in particular [[rel-home#use_with_rel-alternate|rel-home with rel-alternate proposal]]

Revision as of 14:34, 3 April 2016

This article is a stub. You can help the microformats.org wiki by expanding it.

Special Combinations

While rel="alternate" does by itself mean that the destination is some alternate representation or version of the current page, it combines in special ways with other rel values and other attributes to provide different more specific meanings, in particular:

With rel stylesheet

Alternate stylesheets

rel="alternate stylesheet" is how you provide an alternate stylesheet for the document. Note that the stylesheet is not an alternate representation of the current page.

With hreflang

Alternate language versions

When used in combination with the hreflang attribute (with a value other than that of the document itself), rel="alternate" means a link to a version of the current document, but in the language indicated by the hreflang attribute.

Example from http://gmpg.org/xfn/creator :

<link href="creator-fr" rel="alternate" hreflang="fr" title="Cr&eacute;ateur XFN 1.1" />

See also: Google Webmaster Tools Help: rel="alternate" hreflang="x" and hreflang

With media

Alternate devices and media

When used in combination with the media attribute, rel="alternate" means a link to a version of the current document, especially for the specified device or medium indicated by the media attribute.

For example, this is one possible way of linking to a site's mobile version:

<a href="http://m.twitter.com" rel="alternate" media="handheld">Twitter mobile site</a>

With type

Page Feed

When used in combination with the type attribute (with a value other than that of the document itself; e.g. other than "text/html"), rel="alternate" means a link to a representation of the contents of the current document in a different format, as designated by the type attribute.

Examples:

<link rel="alternate" type="application/rss+xml" href=".rss"
      title="RSS feed for this page"/>
<link rel="alternate" type="application/atom+xml" href=".atom"
      title="Atom feed for this page"/>
<link rel="alternate" type="application/activitystream+json" href=".as"
      title="Activity Streams JSON feed for this page"/>

With type and rel home

Site Feed

Main article: rel-home#use_with_rel-alternate

Proposed: When used in combination with the type attribute (with a value other than that of the document itself, e.g. other than "text/html"), rel="alternate home" means a link to a representation of the contents of the site (the home page for the current page) in a different format, as designated by the type attribute.

Examples:

<link rel="alternate home" type="application/rss+xml" href=".rss"
      title="RSS feed for this site"/>
<link rel="alternate home" type="application/atom+xml" href=".atom"
      title="Atom feed for this site"/>
<link rel="alternate home" type="application/activitystream+json" href=".as"
      title="Activity Streams JSON feed for this site"/>

See Also