HTML Tag Reference - HTML tag <output>








The <output> element represents the result of a calculation.

Browser compatibility

<output> Yes Yes Yes Yes Yes

What's new in HTML5

The <output> tag is new in HTML5.

Attribute

Attribute Value Description
for element_id Set the relationship between the result and the elements
form form_id Set one or more owner forms
name name Set a name for the output element




Global Attributes

The <output> tag supports the Global Attributes in HTML.

Event Attributes

The <output> tag supports the Event Attributes in HTML.

Default CSS Settings

output {
    display: inline;
}

Example

A demo showing how to use <output> tag.

<!DOCTYPE HTML>
<html>
<body>
   <form onsubmit="return false"
      oninput="res.value = quant.valueAsNumber * price.valueAsNumber">
      <fieldset>
            <legend>Price Calculator</legend>
            <input type="number" 
                   placeholder="Quantity" 
                   id="quant" 
                   name="quant" />
            x <!--   ww w  .j  a  v a2s  .co m-->
            <input type="number" 
                   placeholder="Price" 
                   id="price" 
                   name="price" />
            =
            <output for="quant name" name="res" />
      </fieldset>
   </form>
</body>
</html>

Click to view the demo