Favorites

DOM Element.children Property

☕
Enjoying this site?

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

Buy us a coffee
Element.children
DOM Element PropertyThis property is supported by all modern browsers.
Updated 28th November 2026

The children property returns a live collection of an element's child elements, ignoring text and comments.

Description

The read-only children property returns a live HTMLCollection of the element's child elements only, without the text and comment nodes that childNodes includes. Use childElementCount or children.length to count them.

Because the collection is live, it updates as children are added or removed, so loop backwards or copy it with Array.from() if you change the children inside the loop. It has no forEach() method, but works with for...of.

Children can also be looked up by index, children[0], or by id or name through namedItem(). childElementCount gives the number of child elements without creating the collection.

Syntax

element.children

Value

A live HTMLCollection of the element's child elements.

Example

<ul id="list">
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
</ul>
const list = document.getElementById('list');
console.log(list.children.length);
for (const li of list.children) console.log(li.textContent);

Browser Support

The following information will show you the current browser support for the Element.children property. Hover over a browser icon to see the version that first introduced support for this property.

This property 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