Skip to main content

5. The Link Header Field

The Link header field provides a means for serializing links in HTTP headers.

Overview

Semantic Equivalence:

  • Equivalent to HTML <LINK> element
  • Equivalent to Atom atom:link feed-level element

ABNF Syntax

Link           = "Link" ":" #link-value
link-value = "`<" URI-Reference ">`" *( ";" link-param )
link-param = ( ( "rel" "=" relation-types )
| ( "anchor" "=" <"> URI-Reference <"> )
| ( "rev" "=" relation-types )
| ( "hreflang" "=" Language-Tag )
| ( "media" "=" ( MediaDesc | ( <"> MediaDesc <"> ) ) )
| ( "title" "=" quoted-string )
| ( "title*" "=" ext-value )
| ( "type" "=" ( media-type | quoted-mt ) )
| ( link-extension ) )
relation-types = relation-type
| <"> relation-type *( 1*SP relation-type ) <">
relation-type = reg-rel-type | ext-rel-type
reg-rel-type = LOALPHA *( LOALPHA | DIGIT | "." | "-" )
ext-rel-type = URI

Components

5.1. Target IRI

  • Conveyed as URI-Reference in angle brackets <>
  • Relative URIs resolved per RFC 3986, Section 5
  • Base IRI from message content NOT applied

5.2. Context IRI

  • Default: IRI of requested resource
  • Override: Use anchor parameter
  • Can specify fragment or third resource
  • Relative URIs resolved per RFC 3986
  • Implementations may ignore anchored links

5.3. Relation Type

  • Specified in rel parameter
  • MUST NOT appear more than once per link-value
  • rev parameter: DEPRECATED (reverse direction)
  • Extension types: must be absolute URIs, quoted if containing ; or ,

5.4. Target Attributes

Standard Parameters:

ParameterDescription
hreflangLanguage hint for target resource
mediaIntended media/medium for style info
titleHuman-readable label
title*Encoded label (RFC 5987)
typeMedia type hint

Usage Rules:

  • hreflang: Can appear multiple times
  • media: Must be quoted if contains ; or ,
  • title: Must NOT appear more than once
  • title*: Preferred over title if both present
  • type: Media type hint, doesn't override Content-Type

5.5. Examples

Simple Navigation:

Link: `\`http://example.com/TheBook/chapter2\``; rel="previous";
title="previous chapter"

Extension Relation:

Link: `</>`; rel="http://example.net/foo"

Multiple Links with Encoding:

Link: `</TheBook/chapter2>`;
rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
`</TheBook/chapter4>`;
rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel

Multiple Relations:

Link: `\`http://example.org/\``;
rel="start http://example.net/relation/other"

See Also: