Documentation: LINK Element Merging

Only Unique REL Attribute Values

Every original LINK element with a REL attribute value of "stylesheet" is imported (exact duplicates are ignored and HREF attribute value matching is case-sensitive). In the interest of speed, HREF values are not canonicalized, so take care to be consistent with precisely how you compose these values if you want to reduce duplication.

All other LINK elements that do not have a REL attribute value of "stylesheet" are handled the same way as META elements; LINK elements with the same REL attribute value that are closest to the resource document will overwrite the HREF attribute value of any LINK in the immediate Master Page with the same REL attribute value and this effect propagates along a chain of Master Pages, if one is created.

Examples

  1. Duplication of the HREF attribute value of a style-sheet LINK results in only one being linked by the final merged document:
    <link rel="stylesheet" type="text/css" href="/css/screen.css" media="screen">
    + <link rel="stylesheet" type="text/css" href="/css/screen.css" media="screen">
    = <link rel="stylesheet" type="text/css" href="/css/screen.css" media="screen">
  2. Any "stylesheet" LINKs in the resource document that are not linked by the immediate Master Page or any other chained Master Pages are imported and appended to the end of the HEAD tag in the final merged document. This ensures that style rules that are closest to the resource document override any conflicting rules that may appear anywhere else in the merge chain:
    <link rel="stylesheet" type="text/css" href="./custom-rules.css" media="all">
    +
    <link rel="stylesheet" type="text/css" href="/css/print.css" media="print">
    <link rel="stylesheet" type="text/css" href="/css/screen.css" media="screen">
    =
    <link rel="stylesheet" type="text/css" href="/css/print.css" media="print">
    <link rel="stylesheet" type="text/css" href="/css/screen.css" media="screen">
    <link rel="stylesheet" type="text/css" href="./custom-rules.css" media="all">
  3. The resource document's icon link overrides the icon specified in the Master Page (and any chained Master Page):
    <link rel="icon" href="./MyCustomFavoritesIcon.ico">
    + <link rel="icon" href="/favicon.ico">
    = <link rel="icon" href="./MyCustomFavoritesIcon.ico">
  4. LINK elements with unique REL values in the resource document are appended verbatim to the end of the immediate Master Page's HEAD tag:
    <link rel="next" href="next-page.html">
    + (no LINK element with REL="next")
    = <link rel="next" href="next-page.html">
  5. LINK elements in a Master Page (immediate or chained) with unique REL values that are not being overridden are left intact and unchanged:
    (no LINK element with REL="search")
    + <link rel="search" href="/widgets/search.html">
    = <link rel="search" href="/widgets/search.html">