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;

  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;

  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);

  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] 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] attribute DOMString? role;
  [CEReactions] attribute Element? ariaActiveDescendantElement;
  [CEReactions] attribute DOMString? ariaAtomic;
  [CEReactions] attribute DOMString? ariaAutoComplete;
  [CEReactions] attribute DOMString? ariaBrailleLabel;
  [CEReactions] attribute DOMString? ariaBrailleRoleDescription;
  [CEReactions] attribute DOMString? ariaBusy;
  [CEReactions] attribute DOMString? ariaChecked;
  [CEReactions] attribute DOMString? ariaColCount;
  [CEReactions] attribute DOMString? ariaColIndex;
  [CEReactions] attribute DOMString? ariaColIndexText;
  [CEReactions] attribute DOMString? ariaColSpan;
  [CEReactions] attribute FrozenArray<Element>? ariaControlsElements;
  [CEReactions] attribute DOMString? ariaCurrent;
  [CEReactions] attribute FrozenArray<Element>? ariaDescribedByElements;
  [CEReactions] attribute DOMString? ariaDescription;
  [CEReactions] attribute FrozenArray<Element>? ariaDetailsElements;
  [CEReactions] attribute DOMString? ariaDisabled;
  [CEReactions] attribute FrozenArray<Element>? ariaErrorMessageElements;
  [CEReactions] attribute DOMString? ariaExpanded;
  [CEReactions] attribute FrozenArray<Element>? ariaFlowToElements;
  [CEReactions] attribute DOMString? ariaHasPopup;
  [CEReactions] attribute DOMString? ariaHidden;
  [CEReactions] attribute DOMString? ariaInvalid;
  [CEReactions] attribute DOMString? ariaKeyShortcuts;
  [CEReactions] attribute DOMString? ariaLabel;
  [CEReactions] attribute FrozenArray<Element>? ariaLabelledByElements;
  [CEReactions] attribute DOMString? ariaLevel;
  [CEReactions] attribute DOMString? ariaLive;
  [CEReactions] attribute DOMString? ariaModal;
  [CEReactions] attribute DOMString? ariaMultiLine;
  [CEReactions] attribute DOMString? ariaMultiSelectable;
  [CEReactions] attribute DOMString? ariaOrientation;
  [CEReactions] attribute FrozenArray<Element>? ariaOwnsElements;
  [CEReactions] attribute DOMString? ariaPlaceholder;
  [CEReactions] attribute DOMString? ariaPosInSet;
  [CEReactions] attribute DOMString? ariaPressed;
  [CEReactions] attribute DOMString? ariaReadOnly;

  [CEReactions] attribute DOMString? ariaRequired;
  [CEReactions] attribute DOMString? ariaRoleDescription;
  [CEReactions] attribute DOMString? ariaRowCount;
  [CEReactions] attribute DOMString? ariaRowIndex;
  [CEReactions] attribute DOMString? ariaRowIndexText;
  [CEReactions] attribute DOMString? ariaRowSpan;
  [CEReactions] attribute DOMString? ariaSelected;
  [CEReactions] attribute DOMString? ariaSetSize;
  [CEReactions] attribute DOMString? ariaSort;
  [CEReactions] attribute DOMString? ariaValueMax;
  [CEReactions] attribute DOMString? ariaValueMin;
  [CEReactions] attribute DOMString? ariaValueNow;
  [CEReactions] 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