Base URL
➔ <meta> tag set the base URL for all the relative urls in the page.
➔ A document can have only one <base> tag.
➔ <base> must specify href or target or both.
Element Attributes
| Attribute | Value | Description |
|---|---|---|
href |
url | The base URL used throughout the document for relative URLs. |
target |
_blank _parent _self _top |
Specify the default browsing context to show results. |
Supported Global attributes
Global attributes may be applied on all elements, although some elements may have no effect on them.
<accesskey>,
<class>,
<contenteditable>,
<contextmenu>,
<data-*>,
<dir>,
<draggable>,
<dropzone>,
<hidden>,
<id>,
<lang>,
<spellcheck>,
<style>,
<tabindex>,
<title>,
<translate>.
Global Event Handler Attributes
This tag does not support any event attributes.
Learning with HTML Editor "Try it Now"
You can edit the HTML code and view the result using online editor.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML base tag example</title>
<base href="/html/">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8" />
<style>
img {
border: 1px solid #40506022;
padding: 10px;
margin: 10px;
}
</style>
</head>
<body>
<h1>HTML base tag example</h1>
<img src="resources/images/birds-kingfisher.png" width="150" height="150" alt="birds">
</body>
</html>
Click on the "Try it Now" button to see how it works.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML base tag example</title>
<base href="https://w3context.com/html/">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8" />
<style>
img {
border: 1px solid #40506022;
padding: 10px;
margin: 10px;
}
</style>
</head>
<body>
<h1>HTML base tag example</h1>
<img src="resources/images/birds-owl.png" width="150" height="150" alt="birds">
</body>
</html>
Click on the "Try it Now" button to see how it works.