👀 Live Preview
Move the slider or change the number to see the sum update:

The <output> tag displays the result of calculations or user actions. This guide covers syntax, key attributes, live form updates, and how to build interactive calculators for beginners.
Show calculated values.
Works inside forms.
Link to input IDs.
oninput recalculates.
Meaningful result text.
Associate with inputs.
<output> Tag?The <output> tag is used to represent the result of a calculation or user action. It is particularly useful when you want to display the outcome of a script or a mathematical operation on a web page.
Unlike a generic <span>, <output> tells browsers and assistive technology that its content is a computed or derived result.
Common uses include live calculators, order totals, quiz scores, and any form field that shows feedback based on user input.
Use the opening <output> tag, place the result text inside, and close with </output>:
<output>Your Output Here</output>form when the result depends on form controls.name when it should submit with the form.for attribute (space-separated).oninput event.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic output | <output>42</output> | Static result |
| Linked inputs | for="a b" | Space-separated IDs |
| Form field | name="result" | Submits with form |
| Live update | oninput="result.value=..." | On parent form |
| Outside form | form="myFormId" | Associates remotely |
| Browser support | Modern 100% | IE 10+ partial |
<output> vs <span>| Element | Purpose | When to use |
|---|---|---|
<output> | Calculation or action result | Form calculators, live totals |
<span> | Generic inline text | Styling or grouping only |
<meter> | Scalar gauge within range | Disk usage, ratings |
The <output> tag supports the for attribute, which associates the output with specific form elements that influence the result:
<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">+
<input type="number" id="b" value="50">
=<output name="result" for="a b">100</output>
</form>for LinkSpace-separated list of element IDs that affect this output.
for="a b"name SubmitForm field name sent when the form is submitted.
name="result"form AssociateID of a form when the output is not nested inside it.
form="calc-form"Display static results, build live calculators, and connect output to form inputs.
Move the slider or change the number to see the sum update:
The <output> tag displays calculation results and script output directly within the HTML document, especially alongside form controls.
The primary purpose of output is to display the result of calculations or script output directly within the HTML document.
<p>The result of the calculation is: <output>42</output></p>Connect the output tag with form elements to display the result of user input or calculations based on form values.
<form oninput="result.value=parseInt(num1.value)+parseInt(num2.value)">
<input type="number" id="num1" value="10">+
<input type="number" id="num2" value="20">
=<output name="result" for="num1 num2">30</output>
</form>label.aria-live on a wrapper for screen readers.Add form controls and an output with matching for IDs.
Typing or sliding triggers the form oninput handler.
Set result.value on the named output element.
Users see calculated results instantly without submitting the form.
The <output> tag is an HTML5 element with full support in all modern browsers and partial support in Internet Explorer 10+.
Chrome, Firefox, Safari, Edge, and Opera all support <output> with form integration.
Bottom line: Use <output> for interactive form calculators in all modern browsers.
Mastering the <output> tag is essential for web developers who need to display dynamic results on their websites. By incorporating this tag effectively, you can provide users with real-time feedback and enhance the interactivity of your web applications.
for to associate output with form inputsoutput with span for semantic resultsname when the value must submitoninput with heavy calculationsoutput<output>Bookmark these before you build interactive forms.
Shows calculated values.
BehaviorLinks to input IDs.
AccessibilityLive form updates.
InteractionSubmits with form.
FormsSemantic for results.
HTML5IE 10+ partial.
Compatibilityoninput on the form and set result.value on a named output element.output for computed form results; use span for generic inline text.Practice <output> with range, number inputs, and the for attribute.
6 people found this page helpful