Open In App

HTML <output> name Attribute

Last Updated : 20 Feb, 2024
Like Article

HTML <output> name attribute specifies the name of the element, which is submitted with the form data when the form is submitted. It’s useful for associating the output with a form element.

HTML <output> name Attribute Syntax: 

<output name="text"> 

HTML <output> name Attribute Values:

It contains the value i.e. name which specifies the name for the <Output> element. 

HTML <output> name Attribute Example: 

In this example, we parse input values, calculate the sum, and display the result in real-time using the output element.


<!DOCTYPE html>
        HTML Output name Attribute
        <h1 style="color:green">
        <h2>HTML Output name Attribute</h2>
        <form oninput="sumresult.value = parseInt(A.value) 
                + parseInt(B.value) + parseInt(C.value)">
            <input type="number" 
                   value="50" /> +
            <input type="range" 
                   value="0" /> +
            <input type="number" 
                   value="30" />
            <br> Result:
            <output name="sumresult">


HTML output name attribute example output

HTML <output> name Attribute Example Explanation:

  • In the above-example ontains a form element with three input fields: two number inputs and one range input.
  • The oninput attribute in the form tag calculates the sum of the values entered in the input fields and assigns it to the output element with the name sumresult.
  • The <output> element displays the result of the calculation dynamically as the inputs change.
  • Users can interact with the inputs to see the real-time sum displayed in the output element.

HTML <output> name Attribute Use Cases

1. How to specify a name for the output element in HTML?

To Specify a name for the output element in HTML using the name attribute within the <output> tag.

2.How to define one or more forms the output element belongs to ?

Here we use the form attribute in the <output> tag to specify one or more forms the output element belongs to.

HTML <output> name Attribute Supported Browsers:

  • Google Chrome 10.0
  • Firefox 4.0
  • Edge 18.0
  • Opera 11.0
  • Apple Safari 7.0

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads