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 elements property of the HTMLFormElement interface returns an HTMLFormControlsCollection listing all the listed form controls associated with the <form> element.
You can access a particular form control in the returned collection by using either an index or the element's name or id attributes.
Prior to HTML 5, the returned object was an HTMLCollection, on which HTMLFormControlsCollection is based.
Independently, you can obtain just the number of associated form controls using the length property. You can get a list of all of the forms contained within a given document using the document's forms property.
An HTMLFormControlsCollection containing all non-image controls associated with the form. This is a live collection; if form controls are associated with or disassociated from the form, this collection will update to reflect the change.
The form controls in the returned collection are in the same order in which they appear in the document by following a preorder, depth-first traversal of the tree. This is called tree order.
Only the following form controls are returned:
In this example, we see how to obtain the list of form controls as well as how to access its members by index and by name or ID.
This example demonstrates how the HTMLFormControlsCollection contains the form controls associated with the form, rather than the controls physically nested in the <form>.
The first form is full, with four form controls: one <fieldset> and three <input> elements. The <legend> and <label> elements are not listed form controls. The second form is sparse, with only one nested form control: a single <object> element. All the form controls in the full form are associated with the sparse form via their form attribute.
We use the elements property to get the HTMLFormControlsCollection for each form.
The collection includes the form element's associated form controls, meaning all the <button>, <fieldset>, <input>, <object>, <output>, <select>, <textarea>, and form-associated custom elements associated with the form, even if those elements are nested in another form, or not nested in any form.
The collection's form controls are in the same order in which they appear in the document.
This example gets the form's element list, then iterates over the list, looking for <input> elements of type "text" so that some form of processing can be performed on them.
| HTML # dom-form-elements-dev |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Nov 3, 2025 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.