The Low Down
<output> element is the semantically correct element for displaying the results of a calculation from form elements.
- Attributes include
name, in addition to the global attributes.
- It does not have the
valueattribute. Rather, the textnode between the opening and closing tags make up the value. The default being the empty string.
- It really doesn’t need the value attribute, since the name/value pair are NOT submitted along with the form
- For the most part, it’s just a simple semantic element that any browser supports in display but not necessarily in function: similar to a
<span>in appearance, but with added functionality.
forattribute takes a space-separated (not comma-separated) list of ID’s of elements that went into calculation.
<output>with a form, which is useful if it is not nested within it.
- If the form is reset, the value will return to its default value.
- Example usage: 1) subtotal, tax and total in a shopping cart, 2) output of a calculator, 3) current value of a range input.
- Example code:
- Article on HTML5 Doctor