This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The HTMLElement interface represents any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it.
Also inherits properties from its parent, Element.
HTMLElement.accessKeyA string representing the access key assigned to the element.
HTMLElement.accessKeyLabel Read only
Returns a string containing the element's assigned access key.
HTMLElement.anchorElement Read only Non-standard Experimental
Returns a reference to the element's anchor element, or null if it doesn't have one.
HTMLElement.attributeStyleMap Read only
A StylePropertyMap representing the declarations of the element's style attribute.
HTMLElement.autocapitalizeA string that represents the element's capitalization behavior for user input. Valid values are: none, off, on, characters, words, sentences.
HTMLElement.autofocusA boolean value reflecting the autofocus HTML global attribute, which indicates whether the control should be focused when the page loads, or when dialog or popover become shown if specified in an element inside <dialog> elements or elements whose popover attribute is set.
HTMLElement.autocorrectA boolean that represents whether or not text input by a user should be automatically corrected. This reflects the autocorrect HTML global attribute.
HTMLElement.contentEditableA string, where a value of true means the element is editable and a value of false means it isn't.
HTMLElement.dataset Read only
Returns a DOMStringMap with which script can read and write the element's custom data attributes (data-*).
HTMLElement.dirA string, reflecting the dir global attribute, representing the directionality of the element. Possible values are "ltr", "rtl", and "auto".
HTMLElement.draggableA boolean value indicating if the element can be dragged.
HTMLElement.editContext Experimental
Returns the EditContext associated with the element, or null if there isn't one.
HTMLElement.enterKeyHintA string defining what action label (or icon) to present for the enter key on virtual keyboards.
A string or boolean value reflecting the value of the element's hidden attribute.
HTMLElement.inertA boolean value 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.
HTMLElement.innerTextRepresents 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. As a setter, it replaces the content inside the selected element, converting any line breaks into <br> elements.
HTMLElement.inputModeA string value reflecting the value of the element's inputmode attribute.
HTMLElement.isContentEditable Read only
Returns a boolean value indicating whether or not the content of the element can be edited.
HTMLElement.langA string representing the language of an element's attributes, text, and element contents.
HTMLElement.nonceReturns the cryptographic number used once that is used by Content Security Policy to determine whether a given fetch will be allowed to proceed.
HTMLElement.offsetHeight Read only
Returns a double containing the height of an element, relative to the layout.
HTMLElement.offsetLeft Read only
Returns a double, the distance from this element's left border to its offsetParent's left border.
HTMLElement.offsetParent Read only
An Element that is the element from which all offset calculations are currently computed.
HTMLElement.offsetTop Read only
Returns a double, the distance from this element's top border to its offsetParent's top border.
HTMLElement.offsetWidth Read only
Returns a double containing the width of an element, relative to the layout.
HTMLElement.outerTextRepresents the rendered text content of a node and its descendants. As a getter, it is the same as HTMLElement.innerText (it represents the rendered text content of an element and its descendants). As a setter, it replaces the selected node and its contents with the given value, converting any line breaks into <br> elements.
HTMLElement.popoverGets and sets an element's popover state via JavaScript ("auto", "hint", or "manual"), and can be used for feature detection. Reflects the value of the popover global HTML attribute.
HTMLElement.spellcheckA boolean value that controls the spell-checking hint. It is available on all HTML elements, though it doesn't affect all of them.
HTMLElement.styleA CSSStyleDeclaration representing the declarations of the element's style attribute.
HTMLElement.tabIndexA long representing the position of the element in the tabbing order.
HTMLElement.titleA string containing the text that appears in a popup box when mouse is over the element.
HTMLElement.translateA boolean value representing the translation.
HTMLElement.virtualKeyboardPolicy Experimental
A string indicating the on-screen virtual keyboard behavior on devices such as tablets, mobile phones, or other devices where a hardware keyboard may not be available, if the element's content is editable (for example, it is an <input> or <textarea> element, or an element with the contenteditable attribute set).
HTMLElement.writingSuggestionsA string indicating if browser-provided writing suggestions should be enabled under the scope of the element or not.
Also inherits methods from its parent, Element.
HTMLElement.attachInternals()Returns an ElementInternals object, and enables a custom element to participate in HTML forms.
HTMLElement.blur()Removes keyboard focus from the currently focused element.
HTMLElement.click()Sends a mouse click event to the element.
HTMLElement.focus()Makes the element the current keyboard focus.
HTMLElement.hidePopover()Hides a popover element by removing it from the top layer and styling it with display: none.
HTMLElement.showPopover()Shows a popover element by adding it to the top layer and removing display: none; from its styles.
HTMLElement.togglePopover()Toggles a popover element between the hidden and showing states.
Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface.
Also, inherits events from its parent, Element.
changeFired when the value of an <input>, <select>, or <textarea> element has been changed and committed by the user. Unlike the input event, the change event is not necessarily fired for each alteration to an element's value.
commandFires on an element that is controlled via a button with valid commandForElement and command values, whenever the button is interacted with (e.g., it is clicked).
errorFired when a resource failed to load, or can't be used.
loadFires for elements containing a resource when the resource has successfully loaded.
dragThis event is fired when an element or text selection is being dragged.
dragendThis event is fired when a drag operation is being ended (by releasing a mouse button or hitting the escape key).
dragenterThis event is fired when a dragged element or text selection enters a valid drop target.
dragleaveThis event is fired when a dragged element or text selection leaves a valid drop target.
dragoverThis event is fired continuously when an element or text selection is being dragged and the mouse pointer is over a valid drop target (every 50 ms WHEN mouse is not moving ELSE much faster between 5 ms (slow movement) and 1ms (fast movement) approximately. This firing pattern is different than mouseover ).
dragstartThis event is fired when the user starts dragging an element or text selection.
dropThis event is fired when an element or text selection is dropped on a valid drop target.
beforetoggleFired when the element is a popover or <dialog>, before it is hidden or shown.
toggleFired when the element is a popover, <dialog>, or <details> element, just after it is hidden or shown.
| Specification |
|---|
| HTML> # htmlelement> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
HTMLElement |
1 | 12 | 1 | 8 | 1 | 18 | 4 | 10.1 | 1 | 1.0 | 1 | 1 |
accessKey |
17 | 12 | 5 | ≤12.1 | 6 | 18 | 5 | ≤12.1 | 6 | 1.0 | 4.4 | 6 |
accessKeyLabel |
No | No | 8 | No | 14 | No | 8 | No | 14 | No | No | 14 |
anchorElement |
preview | No | No | No | No | No | No | No | No | No | No | No |
attachInternals |
77 | 79 | 93 | 64 | 16.4 | 77 | 93 | 55 | 16.4 | 12.0 | 77 | 16.4 |
attributeStyleMap |
66 | 79 | No | 53 | 16.4 | 66 | No | 47 | 16.4 | 9.0 | 66 | 16.4 |
autocapitalize |
6643–66Supported onHTMLInputElement and HTMLTextAreaElement only. |
79 | 111 | 5330–53Supported onHTMLInputElement and HTMLTextAreaElement only. |
No | 6643–66Supported onHTMLInputElement and HTMLTextAreaElement only. |
111 | 4730–47Supported onHTMLInputElement and HTMLTextAreaElement only. |
10.3≤3–10.3Supported onHTMLFormElement, HTMLInputElement, and HTMLTextAreaElement only. |
9.04.0–9.0Supported onHTMLInputElement and HTMLTextAreaElement only. |
6643–66Supported onHTMLInputElement and HTMLTextAreaElement only. |
10.3≤3–10.3Supported onHTMLFormElement, HTMLInputElement, and HTMLTextAreaElement only. |
autocorrect |
No | No | 136 | No | 14.1 | No | 136 | No | 14.5 | No | No | 14.5 |
autofocus |
791–79Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
7912–79Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
1101–110Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
66≤12.1–66Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
15.44–15.4Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
7918–79Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
1104–110Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
57≤12.1–57Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
15.43.2–15.4Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
12.01.0–12.0Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
794.4–79Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
15.43.2–15.4Supported forHTMLButtonElement, HTMLInputElement, HTMLSelectElement, and HTMLTextAreaElement. |
beforetoggle_event |
114 | 114 | 125 | 100 | 17 | 114 | 125 | 76 | 17 | 23.0 | 114 | 17 |
blur |
1 | 12 | 1.5 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
change_event |
1 | 12 | 1 | 9 | 3 | 18 | 4 | 10.1 | 2 | 1.0 | 4.4 | 2 |
click |
9Before Chrome 19,click() is only defined on buttons and inputs. |
12 | 3["Before Firefox 5,click() is only defined on buttons and inputs, and has no effect on text and file inputs.", "Starting in Firefox 75, the click() function works even when the element is not attached to a DOM tree."] |
10.5 | 6 | 18Before Chrome Android 25,click() is only defined on buttons and inputs. |
4["Before Firefox 5,click() is only defined on buttons and inputs, and has no effect on text and file inputs.", "Starting in Firefox for Android 79, the click() function works even when the element is not attached to a DOM tree."] |
11 | 6 | 1.0Before Samsung Internet 1.5,click() is only defined on buttons and inputs. |
4.4Before WebView Android 4.4,click() is only defined on buttons and inputs. |
6 |
command_event |
135 | 135 | preview | 120 | preview | 135 | No | 89 | No | No | 135 | No |
contentEditable |
1 | 12 | 3 | 9 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
dataset |
7 | 12 | 6 | 11 | 5.1 | 18 | 6 | 11 | 5 | 1.0 | 3 | 5 |
dir |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
drag_event |
1 | 12 | 9 | 12 | 3.1 | 18 | 9 | 12 | 2 | 1.0 | 4.4 | 2 |
dragend_event |
1 | 12 | 9 | 12 | 3.1 | 18 | 9 | 12 | 2 | 1.0 | 4.4 | 2 |
dragenter_event |
1 | 12 | 9 | 12 | 3.1 | 18 | 9 | 12 | 2 | 1.0 | 4.4 | 2 |
dragexit_event |
No | 12–79 | 3.5 | 12 | 3.1 | No | 4 | No | No | No | No | No |
draggable |
4 | 12 | 2 | 12 | 5 | 18 | 4 | 12 | 4 | 1.0 | 4.4 | 4 |
dragleave_event |
1 | 12 | 9 | 12 | 3.1 | 18 | 9 | 12 | 2 | 1.0 | 4.4 | 2 |
dragover_event |
1 | 12 | 9 | 12 | 3.1 | 18 | 9 | 12 | 2 | 1.0 | 4.4 | 2 |
dragstart_event |
1 | 12 | 9 | 12 | 3.1 | 18 | 9 | 12 | 2 | 1.0 | 4.4 | 2 |
drop_event |
1 | 12 | 9 | 12 | 3.1 | 18 | 9 | 12 | 2 | 1.0 | 4.4 | 2 |
editContext |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
enterKeyHint |
77 | 79 | 94 | 64 | 13.1 | 77 | 94 | 55 | 13.4 | 12.0 | 77 | 13.4 |
error_event |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
focus |
1 | 12 | 1.5 | 8 | 3 | 18 | 4 | 10.1 | 1If there's no hardware keyboard connected and the user has not yet interacted with the page, then callingfocus() on an <input> element has no effect (for example, the element does not match the :focus selector). |
1.0 | 4.4 | 1If there's no hardware keyboard connected and the user has not yet interacted with the page, then callingfocus() on an <input> element has no effect (for example, the element does not match the :focus selector). |
hidden |
6 | 12 | 4 | 11.6 | 5.1 | 18 | 4 | 12 | 5 | 1.0 | 3 | 5 |
hidePopover |
114 | 114 | 125 | 100 | 17 | 114 | 125 | 76 | 17 | 23.0 | 114 | 17 |
inert |
102 | 102 | 112 | 88 | 15.5 | 102 | 112 | 70 | 15.5 | 19.0 | 102 | 15.5 |
innerText |
1 | 12 | 45 | 9.6 | 1 | 18 | 45 | 10.1 | 1 | 1.0 | 1 | 1 |
inputMode |
66 | 79 | 95 | 53 | 12.1 | 66 | 79 | 47 | 12.2 | 9.0 | 66 | 12.2 |
isContentEditable |
1 | 12 | 4 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
lang |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
load_event |
1 | 12 | 1 | 8 | 1.3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
nonce |
61 | 79 | 75 | 48 | 15.410–15.4The property is defined only for its useful elements:<link>, <script>, and <style>; it is undefined for all other elements. |
61 | 79 | 45 | 15.410–15.4The property is defined only for its useful elements:<link>, <script>, and <style>; it is undefined for all other elements. |
8.0 | 61 | 15.410–15.4The property is defined only for its useful elements:<link>, <script>, and <style>; it is undefined for all other elements. |
offsetHeight |
1 | 12 | 1 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
offsetLeft |
1 | 12 | 1 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
offsetParent |
1 | 12 | 1 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
offsetTop |
1 | 12 | 1 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
offsetWidth |
1 | 12 | 1 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
outerText |
1 | 12 | 98 | ≤12.1 | 1.3 | 18 | 98 | ≤12.1 | 1 | 1.0 | 1 | 1 |
popover |
114 | 114 | 125 | 100 | 17 | 114 | 125 | 76 | 18.317–18.3On iOS and iPadOS, popovers are not dismissed when the user taps outside of the popover area, see bug 267688. |
23.0 | 114 | 18.317–18.3On iOS and iPadOS, popovers are not dismissed when the user taps outside of the popover area, see bug 267688. |
showPopover |
114 | 114 | 125 | 100 | 17 | 114 | 125 | 76 | 17 | 23.0 | 114 | 17 |
spellcheck |
9 | 12 | 2 | ≤12.1 | 5.1 | 18 | 4 | ≤12.1 | 5 | 1.0 | 3 | 5 |
style |
1 | 12 | 1 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
tabIndex |
1 | 1812–18Returns incorrect value for elements without an explicit tabindex attribute. See issue 4365703 for details. |
1 | ≤12.1 | 3.1 | 18 | 4 | ≤12.1 | 2 | 1.0 | 4.4 | 2 |
title |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
togglePopover |
114 | 114 | 125 | 100 | 17 | 114 | 125 | 76 | 17 | 23.0 | 114 | 17 |
toggle_event |
36 | 79 | 49 | 23 | 10.1 | 36 | 49 | 24 | 10.3 | 3.0 | 37 | 10.3 |
translate |
19 | 79 | 111 | 15 | 6 | 25 | 111 | 14 | 6 | 1.5 | 4.4 | 6 |
virtualKeyboardPolicy |
94 | 94 | No | 80 | No | 94 | No | 66 | No | 17.0 | 94 | No |
writingSuggestions |
124 | 124 | No | 110 | 18 | 124 | No | 82 | 18 | 27.0 | 124 | 18 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement