HTML 5 <output> Tag
<output> tag is used for representing the result of a calculation or user action. This could inlude displaying the results of a calculation performed by a script, or it could display the output of a user's interaction with a form element.
<output> tag was introduced in HTML 5.
This example uses the
<output> element to display the result of an interest rate calculation, based on user input. The
<output> element is also used to display the result of the
range slider as the user adjusts the interest rate.
HTML tags can contain one or more attributes. Attributes are added to a tag to provide the browser with more information about how the tag should appear or behave. Attributes consist of a name and a value separated by an equals (=) sign, with the value surrounded by double quotes. Here's an example,
There are 3 kinds of attributes that you can add to your HTML tags: Element-specific, global, and event handler content attributes.
The attributes that you can add to this tag are listed below.
The following table shows the attributes that are specific to this tag/element.
|for||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. The value must be a list of IDs (separated by a space) of elements within the same document.|
|form||Associates the output with a form.|
|name||Specifies the name of this element.|
The following attributes are standard across all HTML 5 tags (although the
tabindex attribute does not apply to
For a full explanation of these attributes, see HTML 5 global attributes.
Event Handler Content Attributes
Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain "event" occurs. Each event handler content attribute deals with a different event.
For a full list of event handlers, see HTML 5 event handler content attributes.