Code has been added to clipboard!

HTML output Tag

Reading time 1 min
Published Jun 29, 2017
Updated Oct 2, 2019

HTML output: Main Tips

  • HTML output element displays the result of a calculation, which is typically performed using JavaScript.
  • It is used along with the <form> and <input> elements.
  • HTML output tag was newly introduced in HTML5 and supports all global attributes.

Usage of HTML Output Element

The content between output HTML tags represents a container where the result of a calculation may be displayed:

Example
<form oninput="result.value=parseInt(x.value)+parseInt(y.value)">
  0<input type="range" id="x" value="75">100
  +<input type="number" id="y" value="72">
  =<output name="result" for="x y"></output>
</form>

Tag Attributes for <output>

The most crucial attributes used with HTML output tags are for and name. The first one specifies the elements used as inputs for the calculation, and the second one names the outputted element:

Example
<form oninput="result.value=parseInt(x.value)+parseInt(y.value)">
  0<input type="range" id="x" value="75">100
  +<input type="number" id="y" value="25">
  =<output name="result" for="x y"></output>
</form>

If your HTML output element is associated with a form control, you can also use the form attribute. It defines the <form> element to which your <output> element belongs:

Example
<form action="process.php" id="sum" oninput="result.value=parseInt(x.value)+parseInt(y.value)">
  0<input type="range" name="x" id="x" value="50">100
  +<input type="number" name="y" id="y" value="50">
  =<output name="result" for="x y"></output>
  <br>
  <input type="submit">
</form>

<output form="sum" name="result" for="x y"></output>

Browser support

Chrome
10+
Edge
All
Firefox
4+
IE
-
Opera
11+
Safari
7+

Mobile browser support

Chrome
All
Firefox
4+
Opera
-
Safari
All
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>