Forms & Inputs

HTML <output> Tag

The <output> tag is used to represent the result of a calculation (like one performed by a script).

Definition and Usage

The <output> tag is used to represent the result of a calculation (like one performed by a script).

Standard Syntax:<output>...</output>

Interactive ExampleRunnable

HTML <output> Example

html
Try it Yourself
Live code demonstration for the <output> tag. Click "Try it Yourself" to edit and experiment in real time.
<div style="font-family: system-ui, sans-serif; padding: 16px; background: #ffffff; border-radius: 8px; border: 1px solid #e2e8f0; color: #0f172a;">
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">

  <input type="range" id="a" value="50">

  +<input type="number" id="b" value="25">

  =<output name="x" for="a b"></output>

 </form>
</div>

Attributes for <output>

3 Supported Attributes
AttributeValuesDefaultDescription
forelement_idnoneSpecifies the relationship between the result of the calculation, and the elements used in the calculation
formform_idnoneSpecifies which form the output element belongs to
namenamenoneSpecifies a name for the output element
Global Attributes

The <output> tag also supports the standard global attributes in HTML, including class, id, style, title, hidden, and data-*.

HTML Global Attributes Reference →
Event Attributes

The <output> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.

HTML Event Attributes Reference →

Browser Compatibility

ChromeEdgeFirefoxSafariOpera

More Tags in Forms & Inputs

View All 123Tags →