What is <output> element in HTML?
In HTML, the <output> element is used to display the result of a calculation. It is a container into which an app or website can inject results or outcomes of an action performed by a user.
Syntax
<output for="" form="" name=""> output content </output>
where:
for: It takeselement_idas value.form: It takesform_idas value. It specifies the<form>element with which the<output>element is associated. The associated<form>should be in the same document.name: It takesnameas value. It specifies the name of the<output>element.
- The value, contents, and name of the
<output>element are not submitted during the form submission.- If the
formattribute is not set, the<output>is associated with its ancestor element.
Example
The following code demonstrates the usage of the <output> element in HTML.
The content we want to be displayed as a result of a calculation is written within the opening and closing tags (<output> and </output>).