Favorites

DOM HTMLElement Interface

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
HTMLElement
DOM InterfaceThis interface is supported by all modern browsers.
Updated 28th November 2026

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

NameDescription
HTMLElement.datasetThe dataset property gives easy access to an element's data-* attributes, as an object with camelCase property names.
HTMLElement.hiddenThe hidden property shows or hides an element by setting its hidden attribute.
HTMLElement.innerTextThe innerText property gets the text of an element as it appears on screen, respecting CSS, or replaces its content with text.
HTMLElement.offsetWidthThe offsetWidth property returns the width of an element as displayed, including padding and border.
HTMLElement.styleThe style property gives access to an element's inline styles, so you can read or change individual CSS properties from JavaScript.

Methods

NameDescription
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

NameDescription
HTMLElement: change eventThe 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 eventThe input event fires every time the value of an input, textarea, select or contenteditable element changes.

Example

<button type="button">Save</button>
const btn = document.querySelector('button');
console.log(btn instanceof HTMLElement, btn instanceof HTMLButtonElement);
btn.style.background = '#2563eb';
btn.style.color = '#fff';
btn.dataset.state = 'ready';
console.log(btn.outerHTML);

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.

This interface is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee