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.
<output for="" form="" name=""> output content </output>
where:
for
: It takes element_id
as value.form
: It takes form_id
as value. It specifies the <form>
element with which the <output>
element is associated. The associated <form>
should be in the same document.name
: It takes name
as 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
form
attribute is not set, the<output>
is associated with its ancestor element.
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>
).