Advertisement
Home Open Editor ❯

HTML <output> form Attribute

Example

<form id="form1" oninput="result.value=parseInt(a.value)+parseInt(b.value)">
  <input type="range" id="b" name="b" value="50" /> +
  <input type="number" id="a" name="a" value="10" />
  <input type="submit">
</form>
=
<output form="form1" name="result" for="a b">50</output>

Try this code ❯

Meaning

The form attribute should be set to the id value of the <form> element that the <output>output element is associated with; otherwise, the nearest parent form is used.

Note: This attribute lets you associate <output> elements to <form>(s) anywhere in the document, not just inside a <form>. It can also override an ancestor <form> element.


Standard Syntax

<output form="formId">...</output>


Advertisement

Attribute Values

Value Description
formId The ID of a form element in the element’s owner
Home Open Editor ❯
Advertisement