HTML <base> Tag

Description

The <base> HTML tag, is used to define the base URL for relative URLs within a web page. It provides a reference point for browsers to resolve relative links and resources like images, stylesheets, and scripts. By setting the base URL with the "href" attribute within the <base> tag, web developers can ensure that all relative URLs on the page are resolved relative to that specified base URL. This tag is particularly useful when a website needs to switch between different domains or directories but wants to maintain consistent URL references for resources across various pages.

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

Attribute Definition
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 table will show you the current browser support for the HTML <base> tag.

Desktop
Edge Chrome Firefox Opera Safari
1211153
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
18414214.4

Last updated by CSSPortal on: 30th March 2024