- Courses
- HTML
- HTML top level tags
- <base>
- Purpose of the base element in HTML
What is the purpose of the <base>
element in a document?
The <base>
element specifies the base URL for all relative URLs in a document.
It ensures that all relative links are resolved against this base URL, providing a consistent reference point for resources. Without it, relative URLs are resolved against the document's location. This is particularly useful when the document is moved to a different directory or server, as it maintains the integrity of the links.
<base href="https://www.example.com/">