The <base> element sets the document base URL used to resolve relative URLs in the page — links, images, stylesheets, scripts, and more. Scripts can read the effective base with document.baseURI.
Put it in <head>. A document may have only one<base>. It must include href, target, or both.
Baseline · Widely available.
Not deprecated. Core support has been stable across browsers since about July 2015.
Use with care.
One wrong base can rewrite every relative URL on the page (including in-page # links). Prefer root-relative paths like /css/style.css unless you truly need a shared base.
Security note.
If target contains a newline, tab, or <, browsers reset it to _blank to reduce dangling-markup injection risks.
Syntax
HTML Syntax
syntax.html
<base href="url">
<base> is a void metadata element: start tag only, no end tag, no children. Place it in <head> before other URL-bearing elements that should use this base.
Reference
Attributes
Provide at least one of these attributes (both are allowed together):
href resolves docs/guide.html against https://example.com/.
target="_blank" opens that result in a new browsing context by default.
If multiple <base> tags appear, only the first href and first target are used.
Edge Cases & Pitfalls
Most base bugs come from surprising URL resolution or placing the tag too late.
anchors
Fragment links use the base too
href="#section" becomes baseURL#section, which can leave the current page. Prefer a full same-document strategy when you use <base>.
order
Place <base> early in <head>
It must come before other elements with URL attributes that should resolve against it.
count
Only one effective base
Extra <base> elements are ignored for later href/target values — use a single tag.
og
Open Graph ignores <base>
Social meta image URLs should be absolute. Relative Open Graph values will not pick up your base.
href
No data: or javascript: bases
Those schemes are not allowed in base href.
security
Odd target characters reset to _blank
Newline, tab, or < in target is sanitized to _blank.
Compatibility
Browser Support
The <base> element is core HTML metadata in every modern browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<base>
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera resolve relative URLs against base. Always test fragment links and third-party meta tags in your own setup.
97%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerAll
Supported
<base>Widely supported
Bottom line: Safe to use when you need a shared document base. Validate relative links, fragments, and social meta URLs carefully.
Remember
Key Takeaways
Role:<base> sets the document base URL and/or default link target.
Placement: one tag in <head>, early, with href and/or target.
Scope: relative URLs only — absolute URLs keep their own address.
Caution: fragment links and Open Graph tags are common surprise areas.
One line: use one early <base> only when many relative URLs must share the same root.
UA style
Default CSS Settings
<base> lives in <head> and is not shown in the page body. Metadata elements are typically not rendered:
default.css
base {
display: none;
}
There is nothing visual to style. Effects appear only through how relative URLs and default targets behave.
Frequently Asked Questions
The base element sets the document base URL used to resolve relative URLs (links, images, scripts, stylesheets, and more). It can also set a default target for links and forms that omit target.
Inside head, and only once per document. It must appear before other elements whose attributes use URLs that should resolve against that base.
You need at least one of them. href sets the base URL; target sets the default browsing context (_self, _blank, _parent, _top, or a frame name).
No. Absolute URLs with a scheme and host keep their own address. Only relative URLs are resolved against the base href.
Fragment-only links like href="#section" are resolved against the base URL, so the browser may request the base page with that fragment instead of jumping in the current document.
Usually no. Prefer root-relative paths like /css/style.css when you can. Use base when many relative paths must share one root (mirrors, static exports, some legacy layouts).