Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The HTMLCollection.length property returns the number of items in a HTMLCollection.
An integer value representing the number of items in a HTMLCollection.
The length property is often useful in DOM programming. It's often used to test the length of a list, to see if it exists at all. It's also commonly used as the iterator in a for loop, as in this example.
| DOM # ref-for-dom-htmlcollection-length① |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 7, 2023 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.