HTML Tags

HTML <output> Tag

The <output> tag is used to display the result of a calculation or user action in a form.
It is commonly used with JavaScript to show dynamic results like sums, percentages, or other computed values.

The <output> element is often linked to one or more input elements using the for attribute.

Syntax

<output for="input1 input2">Result</output>

Attributes

AttributeDescription
forLists IDs of elements that contribute to the output.
formAssociates the output with a specific form.
nameAssigns a name to the output element.
idAssigns a unique ID.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Output Tag Example</title>
</head>
<body>
  <h2>Sum Calculator</h2>
  <form oninput="result.value = parseInt(num1.value) + parseInt(num2.value)">
        <label for="num1">Number 1:</label>
        <input type="number" id="num1" value="">
        <br>
        <label for="num2">Number 2:</label>
        <input type="number" id="num2" value="">
        <br>
        <br>
        Output = <output name="result" for="num1 num2"></output>
   </form>
</body>
</html>

Output

Browser Output

You will see two number input fields.
As you type numbers, the sum is dynamically displayed in the output element.
Use our TryIt Editor to experiment with live calculation updates.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

All major browser supports <output> tag.

Notes

  • The <output> element is designed for displaying calculated results.
  • Can be linked to one or more inputs using the for attribute.
  • Supports dynamic updates via JavaScript.
  • Improves form clarity by showing real-time results without additional labels.

Conclusion

The <output> tag is useful for displaying results in forms dynamically.
It provides a semantic way to show calculations or other computed outputs in modern HTML.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend