HTML Tags
HTML <base> Tag
The <base> tag specifies a base URL and a default target for all relative URLs on the page.
What is the <base> tag?
The <base> element specifies the base URL to use for all relative URLs in a document, and an optional default browsing context (target) for hyperlinks and forms. It is a void element placed inside the <head>, and a document may contain at most one <base>.
Syntax
<base href="https://example.com/pages/" target="_blank" />Complete example
<!DOCTYPE html>
<html lang="en">
<head>
<base href="https://myinternships.in/docs/" />
</head>
<body>
<!-- Resolves to https://myinternships.in/docs/guide.html -->
<a href="guide.html">Read the guide</a>
</body>
</html>Attributes
| Attribute | Description |
|---|---|
| href | The base URL used for every relative URL in the document. |
| target | The default browsing context for links and forms: _self, _blank, _parent or _top. |
⚠️
Only the first <base> element on a page is used; any additional ones are ignored. Because it affects all relative URLs, place it carefully and test navigation.
The <base> tag is supported in all browsers. At least one of href or target must be present for the element to have any effect.
