Warning:
This wiki has been archived and is now read-only.

Elements/output

From HTML Wiki
Jump to: navigation, search

<output>

The <output> element represents the result of a calculation.

HTML Attributes

  • for = unordered set of unique space-separated tokens
    Allows an explicit relationship to be made between the result of a calculation and the elements that represent the values that went into the calculation or that otherwise influenced the calculation.
    This attribute must have the value of an ID of an element in the same Document.[Example B]


  • form = the ID of a form element in the element's owner
    Associate the output element with its form owner.
    By default, the output element is associated with its nearest ancestor form element.


  • name = unique name
    Represents the element's name.


See also global attributes.


Examples

Example A

A simple calculator could use output for its display of calculated results [try it]:

<form onsubmit="return false">
  <input name="a" type="number" step="any"> +
  <input name="b" type="number" step="any"> =
  <output onforminput="value = a.valueAsNumber + b.valueAsNumber"></output>
</form>

Example B

The following example is the one for the use of the for attribute [try it]:

<form onsubmit="return false">
  <input id="a" name="a" type="number" step="any"> +
  <input id="b" name="b" type="number" step="any"> =
  <output for="a b"  onforminput="value = a.valueAsNumber + b.valueAsNumber"></output>
</form>

HTML Reference

The HTML5 specification defines the <output> element in 4.10.15 The output element.