HTML Tutorial
<base>
tag within the <head>
element of the HTML document.href
attribute to specify the base URL.<head>
<base href="https://example.com/">
...
</head>
This will make all relative URLs in the document use https://example.com/
as the base URL. For example, the following link will resolve to https://example.com/about
:
<a href="about">...</a>
Exploring the <base>
Tag:
Consider the following HTML example:
<!DOCTYPE html>
<html>
<head>
<base href="https://example.com/">
</head>
<body>
<img src="image1.jpg">
</body>
</html>
In this example, the <base>
tag sets the base URL to https://example.com/
. Therefore, the src
attribute of the <img>
tag will resolve to https://example.com/image1.jpg
, even though only the relative path is specified.