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
htmlLive 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| Attribute | Values | Default | Description |
|---|---|---|---|
| for | element_id | none | Specifies the relationship between the result of the calculation, and the elements used in the calculation |
| form | form_id | none | Specifies which form the output element belongs to |
| name | name | none | Specifies 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-*.
Event Attributes
The <output> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.
Browser Compatibility
ChromeEdgeFirefoxSafariOpera
More Tags in Forms & Inputs
View All 123Tags →<button>The <button> tag defines a clickable button.<datalist>The <datalist> tag specifies a list of pre-defined options for an <input> element.<fieldset>The <fieldset> tag is used to group related elements in a form.<form>The <form> tag is used to create an HTML form for user input.<input>The <input> tag specifies an input field where the user can enter data.<label>The <label> tag defines a label for several elements: