HTML <base>
query_builder | Christopher PisaniThe <base> element places a URL as a base link to what files are relative to in a document. It is very useful when altering the main URL through the .htaccess file when working online or when working offline in development mode.
Only one <base> element is supported per page. If a second <base> element is present, only the first link will be obeyed, the others will be ignored.
This element should be placed in the head section of the document.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sample page</title>
<base href="https://www.example.com/">
<base target="_blank">
<base target="_top" href="https://example.com/">
</head>
<body>
<!-- The href will automatically be transformed to https://www.example.com/info.html -->
<a href="info.html">Check url when clicked</a>
<!-- This link will take you to the element with id 'exampleID' in www.example.com -->
<a href="#exampleID">Example id follower</a>
</body>
</html>
Available Attributes
Attribute | Values | Functionality |
---|---|---|
href | url | The link the files will be relative to |
target | _blank _parent _self _top |
The target for all the links in the document |