WebIDLpedia

Element interface

Definition

DOM Standard defines Element


Element includes ParentNode;
Element includes NonDocumentTypeChildNode;
Element includes ChildNode;
Element includes Slottable;

[Exposed=Window]
interface Element : Node {
  readonly attribute DOMString? namespaceURI;
  readonly attribute DOMString? prefix;
  readonly attribute DOMString localName;
  readonly attribute DOMString tagName;

  [CEReactions] attribute DOMString id;
  [CEReactions] attribute DOMString className;
  [SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
  [CEReactions, Unscopable] attribute DOMString slot;

  boolean hasAttributes();
  [SameObject] readonly attribute NamedNodeMap attributes;
  sequence<DOMString> getAttributeNames();
  DOMString? getAttribute(DOMString qualifiedName);
  DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
  [CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
  [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value);
  [CEReactions] undefined removeAttribute(DOMString qualifiedName);
  [CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName);
  [CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
  boolean hasAttribute(DOMString qualifiedName);
  boolean hasAttributeNS(DOMString? namespace, DOMString localName);

  Attr? getAttributeNode(DOMString qualifiedName);
  Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName);
  [CEReactions] Attr? setAttributeNode(Attr attr);
  [CEReactions] Attr? setAttributeNodeNS(Attr attr);
  [CEReactions] Attr removeAttributeNode(Attr attr);

  ShadowRoot attachShadow(ShadowRootInit init);
  readonly attribute ShadowRoot? shadowRoot;

  readonly attribute CustomElementRegistry? customElementRegistry;

  Element? closest(DOMString selectors);
  boolean matches(DOMString selectors);
  boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches

  HTMLCollection getElementsByTagName(DOMString qualifiedName);
  HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
  HTMLCollection getElementsByClassName(DOMString classNames);

  [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
  undefined insertAdjacentText(DOMString where, DOMString data); // legacy
};

This interface is extended in the following specifications:

Consolidated IDL (across mixin and partials)


[Exposed=Window]
interface Element : Node {
  readonly attribute DOMString? namespaceURI;
  readonly attribute DOMString? prefix;
  readonly attribute DOMString localName;
  readonly attribute DOMString tagName;

  [CEReactions] attribute DOMString id;
  [CEReactions] attribute DOMString className;
  [SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
  [CEReactions, Unscopable] attribute DOMString slot;

  boolean hasAttributes();
  [SameObject] readonly attribute NamedNodeMap attributes;
  sequence<DOMString> getAttributeNames();
  DOMString? getAttribute(DOMString qualifiedName);
  DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
  [CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
  [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value);
  [CEReactions] undefined removeAttribute(DOMString qualifiedName);
  [CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName);
  [CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
  boolean hasAttribute(DOMString qualifiedName);
  boolean hasAttributeNS(DOMString? namespace, DOMString localName);

  Attr? getAttributeNode(DOMString qualifiedName);
  Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName);
  [CEReactions] Attr? setAttributeNode(Attr attr);
  [CEReactions] Attr? setAttributeNodeNS(Attr attr);
  [CEReactions] Attr removeAttributeNode(Attr attr);

  ShadowRoot attachShadow(ShadowRootInit init);
  readonly attribute ShadowRoot? shadowRoot;

  readonly attribute CustomElementRegistry? customElementRegistry;

  Element? closest(DOMString selectors);
  boolean matches(DOMString selectors);
  boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches

  HTMLCollection getElementsByTagName(DOMString qualifiedName);
  HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
  HTMLCollection getElementsByClassName(DOMString classNames);

  [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
  undefined insertAdjacentText(DOMString where, DOMString data);
  [SameObject] readonly attribute HTMLCollection children;
  readonly attribute Element? firstElementChild;
  readonly attribute Element? lastElementChild;
  readonly attribute unsigned long childElementCount;

  [CEReactions, Unscopable] undefined prepend((Node or DOMString)... nodes);
  [CEReactions, Unscopable] undefined append((Node or DOMString)... nodes);
  [CEReactions, Unscopable] undefined replaceChildren((Node or DOMString)... nodes);

  [CEReactions] undefined moveBefore(Node node, Node? child);

  Element? querySelector(DOMString selectors);
  [NewObject] NodeList querySelectorAll(DOMString selectors);
  readonly attribute Element? previousElementSibling;
  readonly attribute Element? nextElementSibling;
  [CEReactions, Unscopable] undefined before((Node or DOMString)... nodes);
  [CEReactions, Unscopable] undefined after((Node or DOMString)... nodes);
  [CEReactions, Unscopable] undefined replaceWith((Node or DOMString)... nodes);
  [CEReactions, Unscopable] undefined remove();
  readonly attribute HTMLSlotElement? assignedSlot;
  Promise<undefined> requestFullscreen(optional FullscreenOptions options = {});

  attribute EventHandler onfullscreenchange;
  attribute EventHandler onfullscreenerror;
  [CEReactions] undefined setHTMLUnsafe((TrustedHTML or DOMString) html);
  DOMString getHTML(optional GetHTMLOptions options = {});

  [CEReactions] attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) innerHTML;
  [CEReactions] attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) outerHTML;
  [CEReactions] undefined insertAdjacentHTML(DOMString position, (TrustedHTML or DOMString) string);
    [CEReactions, Reflect] attribute DOMString elementTiming;
    Node getSpatialNavigationContainer();
    sequence<Node> focusableAreas(optional FocusableAreasOption option = {});
    Node? spatialNavigationSearch(SpatialNavigationDirection dir, optional SpatialNavigationSearchOptions options = {});
  CSSPseudoElement? pseudo(CSSOMString type);
  readonly attribute CSSOMString regionOverset;
  sequence<Range>? getRegionFlowRanges();
  [SameObject, PutForwards=value] readonly attribute DOMTokenList part;
    [SameObject] StylePropertyMapReadOnly computedStyleMap();
  DOMRectList getClientRects();
  [NewObject] DOMRect getBoundingClientRect();

  boolean checkVisibility(optional CheckVisibilityOptions options = {});

  undefined scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = {});
  undefined scroll(optional ScrollToOptions options = {});
  undefined scroll(unrestricted double x, unrestricted double y);
  undefined scrollTo(optional ScrollToOptions options = {});
  undefined scrollTo(unrestricted double x, unrestricted double y);
  undefined scrollBy(optional ScrollToOptions options = {});
  undefined scrollBy(unrestricted double x, unrestricted double y);
  attribute unrestricted double scrollTop;
  attribute unrestricted double scrollLeft;
  readonly attribute long scrollWidth;
  readonly attribute long scrollHeight;
  readonly attribute long clientTop;
  readonly attribute long clientLeft;
  readonly attribute long clientWidth;
  readonly attribute long clientHeight;
  readonly attribute double currentCSSZoom;
  sequence<DOMQuad> getBoxQuads(optional BoxQuadOptions options = {});
  DOMQuad convertQuadFromNode(DOMQuadInit quad, GeometryNode from, optional ConvertCoordinateOptions options = {});
  DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options = {});
  DOMPoint convertPointFromNode(DOMPointInit point, GeometryNode from, optional ConvertCoordinateOptions options = {});
  undefined setPointerCapture (long pointerId);
  undefined releasePointerCapture (long pointerId);
  boolean hasPointerCapture (long pointerId);
  Promise<undefined> requestPointerLock(optional PointerLockOptions options = {});
[CEReactions, Reflect] attribute DOMString? role;
[CEReactions, Reflect="aria-activedescendant"] attribute Element? ariaActiveDescendantElement;
[CEReactions, Reflect="aria-atomic"] attribute DOMString? ariaAtomic;
[CEReactions, Reflect="aria-autocomplete"] attribute DOMString? ariaAutoComplete;
[CEReactions, Reflect="aria-braillelabel"] attribute DOMString? ariaBrailleLabel;
[CEReactions, Reflect="aria-brailleroledescription"] attribute DOMString? ariaBrailleRoleDescription;
[CEReactions, Reflect="aria-busy"] attribute DOMString? ariaBusy;
[CEReactions, Reflect="aria-checked"] attribute DOMString? ariaChecked;
[CEReactions, Reflect="aria-colcount"] attribute DOMString? ariaColCount;
[CEReactions, Reflect="aria-colindex"] attribute DOMString? ariaColIndex;
[CEReactions, Reflect="aria-colindextext"] attribute DOMString? ariaColIndexText;
[CEReactions, Reflect="aria-colspan"] attribute DOMString? ariaColSpan;
[CEReactions, Reflect="aria-controls"] attribute FrozenArray<Element>? ariaControlsElements;
[CEReactions, Reflect="aria-current"] attribute DOMString? ariaCurrent;
[CEReactions, Reflect="aria-describedby"] attribute FrozenArray<Element>? ariaDescribedByElements;
[CEReactions, Reflect="aria-description"] attribute DOMString? ariaDescription;
[CEReactions, Reflect="aria-details"] attribute FrozenArray<Element>? ariaDetailsElements;
[CEReactions, Reflect="aria-disabled"] attribute DOMString? ariaDisabled;
[CEReactions, Reflect="aria-errormessage"] attribute FrozenArray<Element>? ariaErrorMessageElements;
[CEReactions, Reflect="aria-expanded"] attribute DOMString? ariaExpanded;
[CEReactions, Reflect="aria-flowto"] attribute FrozenArray<Element>? ariaFlowToElements;
[CEReactions, Reflect="aria-haspopup"] attribute DOMString? ariaHasPopup;
[CEReactions, Reflect="aria-hidden"] attribute DOMString? ariaHidden;
[CEReactions, Reflect="aria-invalid"] attribute DOMString? ariaInvalid;
[CEReactions, Reflect="aria-keyshortcuts"] attribute DOMString? ariaKeyShortcuts;
[CEReactions, Reflect="aria-label"] attribute DOMString? ariaLabel;
[CEReactions, Reflect="aria-labelledby"] attribute FrozenArray<Element>? ariaLabelledByElements;
[CEReactions, Reflect="aria-level"] attribute DOMString? ariaLevel;
[CEReactions, Reflect="aria-live"] attribute DOMString? ariaLive;
[CEReactions, Reflect="aria-modal"] attribute DOMString? ariaModal;
[CEReactions, Reflect="aria-multiline"] attribute DOMString? ariaMultiLine;
[CEReactions, Reflect="aria-multiselectable"] attribute DOMString? ariaMultiSelectable;
[CEReactions, Reflect="aria-orientation"] attribute DOMString? ariaOrientation;
[CEReactions, Reflect="aria-owns"] attribute FrozenArray<Element>? ariaOwnsElements;
[CEReactions, Reflect="aria-placeholder"] attribute DOMString? ariaPlaceholder;
[CEReactions, Reflect="aria-posinset"] attribute DOMString? ariaPosInSet;
[CEReactions, Reflect="aria-pressed"] attribute DOMString? ariaPressed;
[CEReactions, Reflect="aria-readonly"] attribute DOMString? ariaReadOnly;
[CEReactions, Reflect="aria-relevant"] attribute DOMString? ariaRelevant;
[CEReactions, Reflect="aria-required"] attribute DOMString? ariaRequired;
[CEReactions, Reflect="aria-roledescription"] attribute DOMString? ariaRoleDescription;
[CEReactions, Reflect="aria-rowcount"] attribute DOMString? ariaRowCount;
[CEReactions, Reflect="aria-rowindex"] attribute DOMString? ariaRowIndex;
[CEReactions, Reflect="aria-rowindextext"] attribute DOMString? ariaRowIndexText;
[CEReactions, Reflect="aria-rowspan"] attribute DOMString? ariaRowSpan;
[CEReactions, Reflect="aria-selected"] attribute DOMString? ariaSelected;
[CEReactions, Reflect="aria-setsize"] attribute DOMString? ariaSetSize;
[CEReactions, Reflect="aria-sort"] attribute DOMString? ariaSort;
[CEReactions, Reflect="aria-valuemax"] attribute DOMString? ariaValueMax;
[CEReactions, Reflect="aria-valuemin"] attribute DOMString? ariaValueMin;
[CEReactions, Reflect="aria-valuenow"] attribute DOMString? ariaValueNow;
[CEReactions, Reflect="aria-valuetext"] attribute DOMString? ariaValueText;
    Animation           animate(object? keyframes,
                                optional (unrestricted double or KeyframeAnimationOptions) options = {});
    sequence<Animation> getAnimations(optional GetAnimationsOptions options = {}); // legacy
};

Methods and attributes that return objects implementing Element

Referring IDL interfaces/dictionaries

Referring specifications