**`<base>`** is a void element placed in `<head>` that changes how every relative URL on the page is resolved — instead of resolving against the current page's own URL, they resolve against whatever `href` you set on `<base>`. There can be **at most one** `<base>` element per document, and it should appear before any other elements that reference URLs (like `<link>` or `<a>`), since it affects everything that follows.
1Understanding <base>
`<base>` is a void element placed in <head> that changes how every relative URL on the page is resolved — instead of resolving against the current page's own URL, they resolve against whatever href you set on <base>. There can be at most one <base> element per document, and it should appear before any other elements that reference URLs (like <link> or <a>), since it affects everything that follows.
A single <base> tag affects EVERY relative URL on the page, including links, images, and form actions — it's easy to accidentally break unrelated links if you add one without auditing the whole page.
<head>
<base href="https://cdn.example.com/assets/">
</head>
<body>
<img src="logo.png"> <!-- loads https://cdn.example.com/assets/logo.png -->
</body>2Practical Example
Here is a real-world application of <base> showing how it is used in production HTML.
<!-- Setting a base target so all links open in a new tab -->
<base href="https://example.com/" target="_blank">3Best Practices
Follow these guidelines when working with <base>:
1. Use <base> only when you deliberately need to redirect all relative URLs to a different root
2. Place it as early as possible in <head>, before other URL-referencing tags
3. Prefer explicit absolute or root-relative URLs over <base> in most cases — it's easy to introduce confusing bugs
Tip: A single <base> tag affects EVERY relative URL on the page, including links, images, and form actions — it's easy to accidentally break unrelated links if you add one without auditing the whole page.
<head>
<base href="https://cdn.example.com/assets/">
</head>
<body>
<img src="logo.png"> <!-- loads https://cdn.example.com/assets/logo.png -->
</body>