Document Metadata

HTML <base> element

Sets a default base URL or target for relative links in the document. Put at most one base element with an href in the head; it affects other relative URLs, including fragment links. A base URL changes resolution for the whole document, including fragment-only URLs. Use it deliberately and place it before other metadata that contains relative URLs. An incorrect base can break navigation and asset loading. It accepts global HTML attributes; individual global features may be inapplicable or restricted.

Formal Syntax & Structure

html syntaxhtml
<base href="https://example.com/docs/">

Parameters & Attributes

NameTypeDescription
hrefURLSpecifies a link destination, resource URL or document base URL depending on the element. An anchor without href is not a normal navigable hyperlink. Relative URLs resolve against the document base URL.
targetbrowsing context name or reserved keywordSelects where a link or form opens. _self uses the current context; _blank requests a new context. Use appropriate opener isolation when opening external pages.

Return Value

HTMLBaseElement

Content model: Empty; this void element cannot contain children and must not have an end tag. No closing tag.

Working Example

Example Snippethtml
<!doctype html><html lang="en">  <head>    <base href="https://example.com/docs/">    <title>Guide</title>  </head>  <body>    <p>Guide</p>  </body></html>
HTML Reference