DOM Interfaces

HTMLBaseElement

Represents the document base URL or default navigation target. Changing a base can change resolution of relative URLs throughout a document. Avoid uncontrolled base values. Example result: https://example.com/docs/.

Formal Syntax & Structure

html syntaxhtml
const element = document.getElementById('demo'); // HTMLBaseElement

Return Value

HTMLBaseElement

An existing HTML DOM object associated with the base element in this example; this interface is a type, not a function return contract.

Working Example

Example Snippethtml
<base id="demo" href="https://example.com/docs/"><p>  Result:  <output id="result"></output></p><script>  const e = document.getElementById('demo');  const result = value => { document.getElementById("result").textContent = String(value); };  result(e.href);</script>
HTML Reference