How to use the <output> tag in HTML?

HTMLWeb DevelopmentFront End Technology

The HTML <output> tag specifies the result of a calculation. Here are the attributes of the <output> tag in HTML −

Attribute
Value
Description
for
for
List of IDs of other elements, i.e it indicates the elements who have contributed input value to the calculation.
form
form
Enables to place output elements anywhere within a document.
name
name
It is the name of the element.


Example

You can try to run the following code to specify the result of a calculation −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Output Tag</title>
   </head>
   <body>
      <form oninput = "result.value = parseInt(a1.value)+parseInt(a2.value)">
         <input type = "range" name = "a1" value = "0" /> +
         <input type = "number" name = "a2" value = "5" /> <br />
          The output is: <output name = "result"></output>
      </form>
   </body>
</html>
raja
Published on 23-Jan-2018 07:12:03
Advertisements