HTML Tags

HTML <base> Tag

The &lt;base&gt; tag specifies the base URL and/or target for all relative URLs in a document.
It defines a reference point so that links and resources (like images, CSS, or JavaScript files) without absolute URLs are resolved relative to the &lt;base&gt; URL.

Syntax

html

<base href="https://example.com/" target="_blank">
  • href: Specifies the base URL for all relative links in the document.
  • target: Defines the default target for all hyperlinks (e.g., _blank, _self, _parent, _top).

Example

html

<!DOCTYPE html>
<html>
<head>
  <title>Base Tag Example</title>
  <base href="https://html5andcss3.org/" target="_blank">
</head>
<body>
  <a href="learn-html/">Learn HTML</a>
  <img src="https://ik.imagekit.io/html5andcss3/browser-icons/chrome.webp" alt="Chrome Logo" width="80">
</body>
</html>

Output

Browser Output

html

<base> tag has no any visible output

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

All major browser supports the &lt;base&gt; tag.

Notes

Conclusion

The &lt;base&gt; tag helps maintain consistent and predictable link behavior across a website by defining a single reference point for all relative URLs. It simplifies development when multiple relative resources share a common base path.