--- title: HTMLElement slug: Web/API/HTMLElement tags: - API - HTML DOM - Interface - NeedsNewLayout - NeedsTranslation - Reference - TopicStub translation_of: Web/API/HTMLElement ---
{{ APIRef("HTML DOM") }}

The HTMLElement interface represents any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it.

{{InheritanceDiagram}}

Properties

Inherits properties from its parent, {{domxref("Element")}}, and implements those from {{domxref("GlobalEventHandlers")}} and {{domxref("TouchEventHandlers")}}.

{{domxref("HTMLElement.accessKey")}}
Is a {{domxref("DOMString")}} representing the access key assigned to the element.
{{domxref("HTMLElement.accessKeyLabel")}} {{readonlyInline}}
Returns a {{domxref("DOMString")}} containing the element's assigned access key.
{{domxref("HTMLElement.contentEditable")}}
Is a {{domxref("DOMString")}}, where a value of "true" means the element is editable and a value of "false" means it isn't.
{{domxref("HTMLElement.isContentEditable")}} {{readonlyInline}}
Returns a {{domxref("Boolean")}} that indicates whether or not the content of the element can be edited.
{{domxref("HTMLElement.contextMenu")}} {{deprecated_inline}}
Is a {{domxref("HTMLMenuElement")}} representing the contextual menu associated with the element. It may be null.
{{domxref("HTMLElement.dataset")}} {{readonlyInline}}
Returns a {{domxref("DOMStringMap")}} with which script can read and write the element's custom data attributes (data-*) .
{{domxref("HTMLElement.dir")}}
Is a {{domxref("DOMString")}}, reflecting the dir global attribute, representing the directionality of the element. Possible values are "ltr", "rtl", and "auto".
{{domxref("HTMLElement.draggable")}}
Is a {{jsxref("Boolean")}} indicating if the element can be dragged.
{{domxref("HTMLElement.dropzone")}} {{readonlyInline}}
Returns a {{domxref("DOMSettableTokenList")}} reflecting the dropzone global attribute and describing the behavior of the element regarding a drop operation.
{{domxref("HTMLElement.hidden")}}
Is a {{jsxref("Boolean")}} indicating if the element is hidden or not.
{{domxref("HTMLElement.inert")}}
Is a {{jsxref("Boolean")}} indicating whether the user agent must act as though the given node is absent for the purposes of user interaction events, in-page text searches ("find in page"), and text selection.
{{domxref("HTMLElement.innerText")}}
Represents the "rendered" text content of a node and its descendants. As a getter, it approximates the text the user would get if they highlighted the contents of the element with the cursor and then copied it to the clipboard.
{{domxref("HTMLElement.itemScope")}} {{experimental_inline}}
Is a {{jsxref("Boolean")}} representing the item scope.
{{domxref("HTMLElement.itemType")}} {{readonlyInline}}{{experimental_inline}}
Returns a {{domxref("DOMSettableTokenList")}}…
{{domxref("HTMLElement.itemId")}} {{experimental_inline}}
Is a {{domxref("DOMString")}} representing the item ID.
{{domxref("HTMLElement.itemRef")}} {{readonlyInline}}{{experimental_inline}}
Returns a {{domxref("DOMSettableTokenList")}}…
{{domxref("HTMLElement.itemProp")}} {{readonlyInline}}{{experimental_inline}}
Returns a {{domxref("DOMSettableTokenList")}}…
{{domxref("HTMLElement.itemValue")}} {{experimental_inline}}
Returns a {{jsxref("Object")}} representing the item value.
{{domxref("HTMLElement.lang")}}
Is a {{domxref("DOMString")}} representing the language of an element's attributes, text, and element contents.
{{domxref("HTMLElement.noModule")}}
Is a {{jsxref("Boolean")}} indicating wether an import script can be executed in user agents that support module scripts.
{{domxref("HTMLElement.nonce")}}
Returns the cryptographic number used once that is used by Content Security Policy to determine whether a given fetch will be allowed to proceed.
{{domxref("HTMLElement.offsetHeight")}} {{readonlyInline}}{{experimental_inline}}
Returns a double containing the height of an element, relative to the layout.
{{domxref("HTMLElement.offsetLeft")}}{{readonlyInline}}{{experimental_inline}}
Returns a double, the distance from this element's left border to its offsetParent's left border.
{{domxref("HTMLElement.offsetParent")}}{{readonlyInline}}{{experimental_inline}}
Returns a {{domxref("Element")}} that is the element from which all offset calculations are currently computed.
{{domxref("HTMLElement.offsetTop")}}{{readonlyInline}}{{experimental_inline}}
Returns a double, the distance from this element's top border to its offsetParent's top border.
{{domxref("HTMLElement.offsetWidth")}}{{readonlyInline}}{{experimental_inline}}
Returns a double containing the width of an element, relative to the layout.
{{domxref("HTMLElement.properties")}} {{readonlyInline}}{{experimental_inline}}
Returns a {{domxref("HTMLPropertiesCollection")}}…
{{domxref("HTMLElement.spellcheck")}}{{ gecko_minversion_inline("1.9")}}
Is a {{jsxref("Boolean")}} that controls spell-checking. It is present on all HTML elements, though it doesn't have an effect on all of them.
{{domxref("HTMLElement.style")}}
Is a {{domxref("CSSStyleDeclaration")}}, an object representing the declarations of an element's style attributes.
{{domxref("HTMLElement.tabIndex")}}
Is a long representing the position of the element in the tabbing order.
{{domxref("HTMLElement.title")}}
Is a {{domxref("DOMString")}} containing the text that appears in a popup box when mouse is over the element.
{{domxref("HTMLElement.translate")}} {{experimental_inline}}
Is a {{jsxref("Boolean")}} representing the translation.

Event handlers

Most event handler properties, of the form onXYZ, are defined on the {{domxref("GlobalEventHandlers")}} or {{domxref("TouchEventHandlers")}} interfaces and implemented by HTMLElement. In addition, the following handlers are specific to HTMLElement.

{{ domxref("HTMLElement.oncopy") }} {{ non-standard_inline() }}
Returns the event handling code for the copy event ({{bug("280959")}}).
{{ domxref("HTMLElement.oncut") }} {{ non-standard_inline() }}
Returns the event handling code for the cut event ({{bug("280959")}}).
{{ domxref("HTMLElement.onpaste") }} {{ non-standard_inline() }}
Returns the event handling code for the paste event ({{bug("280959")}}).
{{domxref("TouchEventHandlers.ontouchstart")}} {{non-standard_inline}}
Returns the event handling code for the {{event("touchstart")}} event.
{{domxref("TouchEventHandlers.ontouchend")}} {{non-standard_inline}}
Returns the event handling code for the {{event("touchend")}} event.
{{domxref("TouchEventHandlers.ontouchmove")}} {{non-standard_inline}}
Returns the event handling code for the {{event("touchmove")}} event.
{{domxref("TouchEventHandlers.ontouchenter")}} {{non-standard_inline}}
Returns the event handling code for the {{event("touchenter")}} event.
{{domxref("TouchEventHandlers.ontouchleave")}} {{non-standard_inline}}
Returns the event handling code for the {{event("touchleave")}} event.
{{domxref("TouchEventHandlers.ontouchcancel")}} {{non-standard_inline}}
Returns the event handling code for the {{event("touchcancel")}} event.

Methods

Inherits methods from its parent, {{domxref("Element")}}.

{{domxref("HTMLElement.blur()")}}
Removes keyboard focus from the currently focused element.
{{domxref("HTMLElement.click()")}}
Sends a mouse click event to the element.
{{domxref("HTMLElement.focus()")}}
Makes the element the current keyboard focus.
{{domxref("HTMLElement.forceSpellCheck()")}} {{experimental_inline}}
Runs the spell checker on the element's contents.

Specifications

Specification Status Comment
{{SpecName('CSSOM View', '#extensions-to-the-htmlelement-interface', 'HTMLElement')}} {{Spec2('CSSOM View')}} Added the following properties: offsetParent, offsetTop, offsetLeft, offsetWidth, and offsetHeight.
{{SpecName('HTML WHATWG', 'elements.html#htmlelement', 'HTMLElement')}} {{Spec2('HTML WHATWG')}} Added the following properties: translate, itemScope, itemType, itemId, itemRef, itemProp, properties, and itemValue.
Added the following method: forceSpellcheck().
Moved the onXYZ attributes to the {{domxref("GlobalEventHandlers")}} interface and added an inheritance from it.
{{SpecName('HTML5 W3C', 'dom.html#htmlelement', 'HTMLElement')}} {{Spec2('HTML5 W3C')}} Added the following properties: dataset, hidden, tabindex, accessKey, accessKeyLabel, draggable, dropzone, contentEditable, isContentEditable, contextMenu, spellcheck, commandType, commandLabel, commandIcon, commandHidden, commandDisabled, commandChecked, style, and all the onXYZ properties.
Moved the id and className properties to the {{domxref("Element")}} interface.
{{SpecName('DOM2 HTML', 'html.html#ID-011100101', 'HTMLElement')}} {{Spec2('DOM2 HTML')}} No change from {{SpecName('DOM2 HTML')}}
{{SpecName('DOM1', 'level-one-html.html#ID-011100101', 'HTMLElement')}} {{Spec2('DOM1')}} Initial definition.

Browser compatibility

{{Compat("api.HTMLElement")}}

See also