- Courses
- HTML
- HTML top level tags
- <base>
- Resolving in-page anchors with base element
How are in-page anchors resolved with the <base>
element?
In-page anchors are resolved with the <base>
element by appending the fragment to the base URL.
This means that a link to an anchor will trigger an HTTP request to the base URL with the fragment attached, rather than just navigating within the page. This behavior ensures that the anchor links are consistent with the base URL, which can be useful for maintaining link integrity when the document is accessed from different locations.
<base href="https://example.com/">
<a href="#section">Go to Section</a> <!-- Resolves to https://example.com/#section -->