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:linkfeed-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
anchorparameter - Can specify fragment or third resource
- Relative URIs resolved per RFC 3986
- Implementations may ignore anchored links
5.3. Relation Type
- Specified in
relparameter - MUST NOT appear more than once per link-value
revparameter: DEPRECATED (reverse direction)- Extension types: must be absolute URIs, quoted if containing ; or ,
5.4. Target Attributes
Standard Parameters:
| Parameter | Description |
|---|---|
hreflang | Language hint for target resource |
media | Intended media/medium for style info |
title | Human-readable label |
title* | Encoded label (RFC 5987) |
type | Media type hint |
Usage Rules:
hreflang: Can appear multiple timesmedia: Must be quoted if contains ; or ,title: Must NOT appear more than oncetitle*: Preferred overtitleif both presenttype: 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: