CSS Portal

HTML <base> Tag

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The <base> HTML element defines the starting point for all relative URLs in an HTML document. It is placed within the <head> section and affects links, images, scripts, and forms throughout the page. Essentially, it tells the browser: “use this URL as the reference for anything that doesn’t have an absolute path.”

By using <base>, developers can simplify URL management. For example, when moving a website to a new domain or reorganizing file structures, relative links automatically adapt without needing to update each individual link. It also ensures that resources referenced relatively behave consistently across the page, preventing broken links or unexpected navigation.

The <base> tag is particularly useful for:

  • Centralizing the reference point for multiple relative links.
  • Controlling the default behavior of links and form submissions.
  • Avoiding errors when copying or restructuring pages across directories or domains.

It’s important to note that <base> can only appear once in a document, and it must be in the <head> section. Its effects are global for the page, so placing it incorrectly or using multiple <base> tags can lead to unexpected behavior.

Properties

Permitted Parents
Any <head> that doesn't contain any other <base> element
Content
None. It is an empty element.
Start/End Tags
Start tag: required, End tag: forbidden

Example

<head>
<base href="https://www.cssportal.com/images/">
<base target="_blank">
</head>

<body>
<img src="arrow.gif">
<a href="https://www.cssportal.com">CSSPortal</a>
</body>

Attributes

href
Specifies a base URL for all relative URLs on a page.
target
Specifies the target frame to load the page into.
Possible Values:
  • _blank
  • _parent
  • _self
  • _top

Global Attributes

The <base> tag also supports the Global Attributes in HTML5

Event Attributes

None

Browser Support

The following information will show you the current browser support for the HTML <base> tag. Hover over a browser icon to see the version that first introduced support for this HTML tag.

This tag is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 25th December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!