Attribute | Description |
Global | Attributes that are available to any HTML5 element. For comprehensive documentation of these attributes see: MDN Global attributes |
name | A string representing the name of an output. As a form element, output can be referenced by it’s name using the document.forms property. This attribute is also used for collecting values on a form submit. |
for | A space separated list of form element ids (e.g. |
form | A string representing the that is associated to the output. If the output is actually outside the , this attribute will ensure that the output still belongs to the and subject to collections and submits of said . |
Output Element Using For and Form Attributes
The following demo features an element’s use of the [for] and [form] attributes. Keep in mind, needs JavaScript in order to function. Inline JavaScript is commonly used in forms as this example demonstrates. Although the elements are type=”number”, their values are not numbers, they are text. So if you require the values to be calculated, you must convert each value into a number using methods such as: parseInt(), parseFloat(), Number(), etc.
Live demo