HTML <base> Element and Relative URLs

The HTML <base> element sets the document base URL used to resolve relative URLs. It belongs inside <head> and is useful only when many relative references should resolve from a location different from the current document URL.

<head>
  <base href="https://www.example.com/docs/">
</head>
<body>
  <a href="guide.html">Guide</a>
</body>

The link resolves to https://www.example.com/docs/guide.html.

Placement in the head Top ↑

If <base> uses href or target, place it before other head elements whose URL-valued attributes should be resolved using that base.

Default link target Top ↑

<base target="_blank"> can set a default browsing context for links, areas and forms without their own target. In most sites it is clearer to set targets only on the specific navigation that needs them.

Important fragment-link caution Top ↑

A fragment such as href="#faq" is also resolved against the base URL. With a different base URL, a link intended to jump within the current page can therefore navigate to the base URL plus that fragment.

Use one effective base URL Top ↑

When multiple <base> elements are present, browsers use only the first href and first target. Keeping one clear base element avoids confusing URL resolution.

Original base URL demo HTML head Meta tags





plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer