Definition
The <output>
tag represents the result of a calculation performed by an application or result of a user action.
Example
<p>This form multiplies two values together:</p>
<form onsubmit="return false" oninput="o.value = a.valueAsNumber * b.valueAsNumber">
<input id=a name=a type=number step=any> *
<input id=b name=b type=number step=any> =
<output name=o for="a b"></output>
</form>
Usage
- Both the opening and closing tag are required.
Attributes
The <output>
element supports the Global Attributes, along with the following:
for
The
for
attribute specifies the variables to be used in calculating the results of the calculation. Thefor
attribute should consist of space-separated tokens that each reference theid
attribute of an element in the same document.form
The
form
attribute specifies the form ID to which the object belongs to. The form ID must be an ID of an element in the same document.name
The
name
attribute specifies the name of the form control to use for form submission.
Best Practices
- Browsers will consider this element as an
aria-live
region. Assistive technology will announce the results without requiring focus is swapped away from the controls producing the result.
Specification
Browser Support
Desktop
Chrome | Edge | Firefox | IE | Opera | Safari |
---|---|---|---|---|---|
Yes | Yes | Yes | No | Yes | Yes |
Mobile
Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |