DOM Interfaces

Element DOM interface

Element is the DOM interface for element nodes, including HTML, SVG and MathML elements. It inherits from Node and provides attributes, selectors and element traversal. HTMLElement is a more specialized interface for HTML elements; not all Element objects are HTMLElement objects. Obtain an existing instance from the DOM rather than calling new Element().

Formal Syntax & Structure

html syntaxhtml
const element = document.querySelector("p");

Return Value

Element

Existing element instance; this interface is a type, not a function return contract.

Working Example

Example Snippethtml
<p id="note">Hello</p><svg aria-hidden="true">  <circle r="5"/></svg><output id="result"></output><script>  const p=document.querySelector("#note"), c=document.querySelector("circle");document.querySelector("#result").textContent=[p instanceof Element,c instanceof Element,c instanceof HTMLElement].join(",");</script>
HTML Reference