HTML / HTML Tags

HTML <Output> Tag

Dec 12, 2022
2 min read
HTML output Tag

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. The for attribute should consist of space-separated tokens that each reference the id 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

ChromeEdgeFirefoxIEOperaSafari
YesYesYesNoYesYes

Mobile

Android WebviewChrome AndroidFirefox AndroidOpera AndroidiOS SafariSamsung Internet
YesYesYesYesYesYes