DOM Properties

Document.forms

Build a form with the HTML form generator

Returns a live collection of form elements in document order. namedItem can find a form by ID or name. Avoid collisions with collection member names. Example result: checkout.

Formal Syntax & Structure

html syntaxhtml
document.forms

Return Value

HTMLCollection

Current document value.

Working Example

Example Snippethtml
<form id="checkout"></form><p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  result.textContent = document.forms.namedItem("checkout").id;  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference