HTML 5 Notes For Professional Chapter 23

Chapter 23: Output Element

AttributeDescription
GlobalAttributes that are available to any HTML5 element. For comprehensive documentation of these
attributes see: MDN Global attributes
nameA 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.
forA space separated list of form element ids (e.g. id=“inp1”> for value is “inp1”) that the output is meant to display calculations for.
formA 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


  
Output Example
+
0

Output Element with Attributes

Pin It on Pinterest

Share This