Documentation: BASE Element Merging

There Can Be Only One

Only one BASE element is allowed in a valid HTML document. As such, if any are specified anywhere in the merge chain, the one closest to the resource document will prevail. This can have undesirable side-effects if you actually rely on this element and you specify different HREF attribute values between the resource document and its Master Page or any other chained Master Pages.

To mitigate unexpected side-effects, it is best to consistently adopt just one of the following strategies for an entire site:

  1. only use the BASE element at the resource document level (not in any Master Pages),
  2. only use the BASE element in one site-wide Master Page that all other resource documents merge with either directly or via Master Page chaining,
  3. assign (and clearly specify the rules for creating) a finite, limited set of Master Pages who may set BASE elements, or
  4. do not use the BASE element.

Examples

  1. Presence of a BASE element in the resource document without any other BASE elements in the merge chain results in the one-and-only BASE element prevailing; this scenario carries the fewest surprises (next only to never using the BASE element):
    <base href="/home/of/many/links">
    + (no BASE element)
    = <base href="/home/of/many/links">
  2. When a BASE element is set in a Master Page, every resource document that is directly or indirectly subordinate to the Master Page will inherit its BASE element; this scenario can introduce surprises like unexpected alterations to links in the final merged document:
    (no BASE element)
    + <base href="/home/of/many/links">
    = <base href="/home/of/many/links">
  3. When a BASE element is set in a resource document and its Master Page, the BASE element set on the resource document will prevail; this is a bad scenario where links specified in the Master Page which depend on its BASE element will be redirected to the BASE path that is specified in the resource document:
    <base href="/alternative/home/of/links">
    + <base href="/home/of/many/links">
    = <base href="/alternative/home/of/links">
  4. When a BASE element is absent from a resource document but is set in its immediate Master Page, and is also set in any chained Master Page, the BASE element that exists on the Master Page that is "nearest" in the merge chain to the resource document will prevail; this creates a worst-case scenario where relative links specified anywhere in the merge chain can exhibit unexpected behavior:
    (no BASE element)
    + <base href="/home/of/many/links">
    + <base href="/alternative/home/of/links">
    = <base href="/home/of/many/links">