HTML output Tag

HTML <output>Tag: The HTML<output> tag defines the result of an calculation which was performed by the client-side script such as JavaScript. And the HTML  output tag is a new tag in HTML 5 and it requires a starting and ends tag. HTML4 does not supports <output> tag.

HTML<output>Tag

This HTML output tag supports both the global and the event attributes.

Syntax: <output> Text </output>

Attributes

The output tag contains three attributes which are listed below:

  • for: This attribute contains an attribute value element_id which is used to specify the relation between result and calculations.
  • form: This attribute contains an attribute value form_id which is used to specify the one or more forms of output elements.
  • name: This attribute contains an attribute value name which is used to specify the name of the output element.

Browser compatibility

The HTML output tag is supported by Chrome-10.0, Firefox-4.0, Opera-11.1, Safari-5.1 and Internet Explorer-13.0.

Example:

<!DOCTYPE html>
<html>
<body>
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
<input type="range" id="a" value="50">1000+<input type="number" id="b" value="100">=<output name="x" for="a b"></output>
</form>
</body>
</html>

Output:

html output tag

Attributes that are supported by the <output> tag

Attribute Value Description
for element_id Specifies the relationship between the result of the calculation, and the elements used in the calculation
form form_id Specifies one or more forms the output element belongs to
name name Specifies a name for the output element