HTML <output> tag

HTML <output> tag : Definition


• The HTML <output> tag is generally used for displaying the result of a calculation(such as JavaScript).

• The <output> tag has been newly added in HTML5 and this element tag is used for complex calculations, like the results of an exchange rate conversion and so on.


Html <output> tag example 1:

<!DOCTYPE html>
<html>
<head>
<title>Output Tag example</title>
</head>
<body>
 <p class="paragraph">Sum of two Numbers</p>
 <form oninput="res.value=parseInt(a.value)+parseInt(b.value);">
  <label>Enter First Value.</label><br>
  <input type="number" name="a" value=""/><br>
  +<br/>
  <label>Enter Second Value.</label><br> 
  <input type="number" name="b" value=""><br>
  =<br>
  Output is:<output name="res"></output>
 </form>
</body>
</html>


Output :


 

Sum of two Numbers



+


=
Output is:

Html <output> tag example 2:

<!DOCTYPE html>
<html>
<body>

<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">
+<input type="number" id="b" value="50">
=<output name="x" for="a b"></output>
</form>

<p><strong>Note:</strong> The output element is not supported in Edge 12 (or earlier).</p>

</body>
</html>

Output:


 
+ Output: =

Note: The output element is not supported in Edge 12 (or earlier).