docs.rodeo

MDN Web Docs mirror

: The Output element

{{HTMLSidebar}} 

The <output> HTML element is a container element into which a site or app can inject the results of a calculation or the outcome of a user action.

Attributes

This element includes the global attributes.

The <output> value, name, and contents are NOT submitted during form submission.

Accessibility

Many browsers implement this element as an aria-live region. Assistive technology will thereby announce the results of UI interactions posted inside it without requiring that focus is switched away from the controls that produce those results.

Examples

In the following example, the form provides a slider whose value can range between 0 and 100, and an {{HTMLElement("input")}}  element into which you can enter a second number. The two numbers are added together, and the result is displayed in the <output> element each time the value of any of the controls changes.

<form id="example-form">
  <input type="range" id="b" name="b" value="50" /> +
  <input type="number" id="a" name="a" value="10" /> =
  <output name="result" for="a b">60</output>
</form>
const form = document.getElementById("example-form");
const a = form.elements["a"];
const b = form.elements["b"];
const result = form.elements["result"];

function updateResult() {
  const aValue = parseInt(a.value);
  const bValue = parseInt(b.value);
  result.value = aValue + bValue;
}

form.addEventListener("input", updateResult);

updateResult();

Result

{{ EmbedLiveSample('Examples')}} 

Technical summary

Content categories Flow content, phrasing content, listed, labelable, resettable form-associated element, palpable content.
Permitted content Phrasing content.
Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that accepts phrasing content.
Implicit ARIA role status
Permitted ARIA roles Any
DOM interface `{{domxref("HTMLOutputElement")}}` 

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

In this article

View on MDN