View video tutorial

HTML <output> Tag

HTML

The <output> tag is used to represent the result.

HTML <output> Tag


➔ An <output> element is a container in which a site or app can insert the results of a calculation.

➔ The <output> element can also be used to show the output of a calculation as a result of user interaction.

Element Attributes

Attribute Value Description
for element_id This specifies the elements that contribute to the calculation.
form form_id This specifies which form the output element belongs to.
name name This specifies the name of the output element.

Supported Global attributes

Global attributes may be applied on all elements, although some elements may have no effect on them.

<accesskey>, <class>, <contenteditable>, <contextmenu>, <data-*>, <dir>, <draggable>, <dropzone>, <hidden>, <id>, <lang>, <spellcheck>, <style>, <tabindex>, <title>, <translate>.

Learning with HTML Editor "Try it Now"

You can edit the HTML code and view the result using online editor.

Example

<!DOCTYPE html>
<html>
<head>
  <title>HTML output tag example</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta charset="utf-8" />
</head>
<body>
  <h1>HTML output tag example</h1>
  <form oninput="r.value=parseInt(a.value)+parseInt(b.value)">
    Number1:<input type="number" id="a" value="1"><br><br>
    Number1:<input type="number" id="b" value="1"><br><br>
    Summation:<output name="r" for="a b"></output>
  </form>
</body>
</html>
Try it Now »

Click on the "Try it Now" button to see how it works.