DOM HTMLElement Interface
HTMLElement is the interface for every HTML element. It adds HTML-specific features to Element, such as style, dataset, hidden, focus() and click().
Description
The HTMLElement interface represents any HTML element. It inherits from Element and adds properties and methods specific to HTML, such as style, dataset, hidden, innerText, title, tabIndex, focus(), blur(), click() and the popover methods.
Many elements have their own more specific interfaces that inherit from it, such as HTMLInputElement, HTMLFormElement, HTMLAnchorElement and HTMLDialogElement. You can also extend it to create your own custom elements with customElements.define().
Many HTML attributes are reflected as properties on the element, so el.title, el.lang and el.tabIndex read and write the matching attributes. Boolean attributes become boolean properties, such as hidden and inert. Events specific to HTML, such as input, change, focus and blur, are commonly handled through listeners on these elements.
Inheritance
HTMLElement inherits properties and methods from Element.
Properties
| Name | Description |
|---|---|
HTMLElement.dataset | The dataset property gives easy access to an element's data-* attributes, as an object with camelCase property names. |
HTMLElement.hidden | The hidden property shows or hides an element by setting its hidden attribute. |
HTMLElement.innerText | The innerText property gets the text of an element as it appears on screen, respecting CSS, or replaces its content with text. |
HTMLElement.offsetWidth | The offsetWidth property returns the width of an element as displayed, including padding and border. |
HTMLElement.style | The style property gives access to an element's inline styles, so you can read or change individual CSS properties from JavaScript. |
Methods
| Name | Description |
|---|---|
HTMLElement.blur() | The blur() method removes keyboard focus from an element. |
HTMLElement.click() | The click() method simulates a mouse click on an element, firing its click event and running its default action. |
HTMLElement.focus() | The focus() method moves keyboard focus to an element, such as a form field or button. |
HTMLElement.showPopover() | The showPopover() method opens an element that has the popover attribute. |
Events
| Name | Description |
|---|---|
HTMLElement: change event | The change event fires when the user commits a change to a form control, such as ticking a checkbox, choosing an option or leaving a text field after editing it. |
HTMLElement: input event | The input event fires every time the value of an input, textarea, select or contenteditable element changes. |
Example
Browser Support
The following information will show you the current browser support for the HTMLElement interface. Hover over a browser icon to see the version that first introduced support for this interface.
Desktop





Tablets & Mobile





