HTML <output>
Published Jun 2, 2022Updated Mar 17, 2023
Contribute to Docs
The <output> element displays the result of a calculation or user action. It is commonly used inside of a <form> element to dynamically show the result of user input. However, the <output> element can be used on its own.
Syntax
The result of 5 + 5 is <output name="operation-result">10</output>
The <output> element requires opening and closing tags that wrap around the result.
Attributes
The <output> element takes the following attributes:
forindicates the id of one or multiple elements (separated by a space) whose values are factored in the calculation.formindicates one or more forms the<output>element belongs to.nameindicates the name of the element.
Example
The example form below features an <output> element displaying the slider value multiplied by two:
<html><head> </head><body><formoninput="result.value=parseInt(sliderInput.value)*2; document.querySelector('span').innerText=sliderInput.value"id="calculation-form"><label for="slideInput" id="sliderValue">Slider Value: <span> </span></label><input name="sliderInput" type="range" value="0" /><label for="result"> Output (Slider value * 2): </label><output name="result" for="sliderInput" form="calculation-form"> </output></form></body></html>

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
- Beginner Friendly.7 hours