CKTIS / JavaScript
HTMLElement: visibility, interaction and element height
Learn hidden, draggable, tabIndex, click(), offsetHeight and title on HTMLElement. Distinguish writable properties, an activation method and a read-only measurement while accounting for keyboard navigation and CSS layout.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
element.hidden = true; // Alternatives: false or "until-found"
element.draggable = true; // Alternative: false
element.tabIndex = integer;
element.click();
const height = element.offsetHeight;
element.title = "Supplementary information";HTMLElement provides browser APIs for HTML elements, not features of ECMAScript itself. Having Node 24 in a project does not establish their availability. The basic features described here are widely supported; check support for the special "until-found" value separately in target browsers.
HTMLElement.hidden reflects the hidden attribute: true means hidden, false means that state is absent, and "until-found" allows content to be revealed by in-page search or fragment navigation. It is not a general visibility test: CSS also affects display. HTMLElement.draggable is a boolean controlling whether an element can be dragged; it does not implement a complete drop operation. The HTML draggable attribute itself is enumerated, not boolean: it uses "true" and "false", while omission means auto behavior.
HTMLElement.tabIndex is an integer. A value of 0 allows an otherwise eligible element to participate in sequential keyboard navigation. Setting it to 0 does not make a hidden or inert element or a disabled control a stop in that sequence. The order depends on focus navigation scopes and does not always match document-wide order. A value of -1 generally keeps the element out of the sequence but still allows programmatic focus if the element can receive focus. Within the same scope, positive values take priority over 0; avoid them to prevent confusing navigation. HTMLElement.click() is a method, not a boolean property: it programmatically triggers a click, except on a disabled form control. It does not substitute for a complete user gesture.
HTMLElement.offsetHeight is read-only: it returns an integer layout height in CSS pixels, including padding, borders and any horizontal scrollbar, but not margins. If the element or an ancestor has display: none, the result is 0. HTMLElement.title holds supplementary information, usually displayed as a tooltip when the pointer hovers over the element.
The example creates an element and a button, sets the properties, invokes click() and reads the height. Explicit dimensions produce an expected 34; after display: none, the expected result is 0. Removing the elements at the end cleans up the document.
Examples
(() => {
const panel = document.createElement("div");
const button = document.createElement("button");
button.type = "button";
button.textContent = "Show panel";
panel.textContent = "Demo";
panel.hidden = true;
panel.draggable = true;
panel.tabIndex = 0;
panel.title = "Demo panel";
panel.style.cssText = "box-sizing:content-box;height:20px;padding:5px;border:2px solid black;overflow:hidden";
document.body.append(button, panel);
let clicks = 0;
button.addEventListener("click", () => {
clicks += 1;
panel.hidden = false;
});
button.click();
console.log(`${panel.hidden} | ${panel.draggable} | ${panel.tabIndex} | ${panel.title} | ${clicks} | ${panel.offsetHeight}`);
panel.hidden = true;
panel.style.display = "none";
console.log(`${panel.hidden} | ${panel.offsetHeight}`);
button.remove();
panel.remove();
})();Result
false | true | 0 | Demo panel | 1 | 34 true | 0
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.
Sources
- HTMLElement - Web APIs | MDN
- HTMLElement: hidden property - Web APIs | MDN
- HTMLElement: draggable property - Web APIs | MDN
- tabindex HTML global attribute - HTML | MDN
- HTMLElement: click() method - Web APIs | MDN
- HTMLElement: offsetHeight property - Web APIs | MDN
- HTMLElement: title property - Web APIs | MDN
- draggable HTML global attribute - HTML | MDN