- Courses
- HTML
- HTML top level tags
- <base>
- Importance of baseURI property in documents
What will console.log(document.baseURI)
output if no <base>
element is present?
The baseURI
property provides the base URL of a document.
It is used by scripts to determine the base URL for resolving relative URLs. If no <base>
element is present, baseURI
defaults to location.href
, ensuring that relative URLs are always resolved correctly. This behavior is crucial for maintaining the integrity of links and resources within a document, especially when the document is accessed from different locations.
console.log(document.baseURI); // Outputs the base URL of the document