Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <output> for Attribute

The for attribute on an <output> tag associates the output to an input element.

The value of this attribute is the id of the input element.

Example

#

An <output> element with a for attribute. The output is associated with the slider input. Move the slider to see the output change.



The value is 25
<form oninput="result.value = slider.value">
  <input type="range" id="slider" value="25"> 
  <br /><br />
  The value is <output name="result" for="slider">25</output>
</form>

Using for

The for attribute on an output element associates the element with an input element.

The value of the for attribute is the id of the input element.

Multiple space-separated id values can be specified, one for each input element that contributes in the calculation.


Syntax

<output for="element-ids">

Values

#

Value Description
element-ids Space-separated list of element ids used in the output's calculation.

Browser support

Here is when for support started for each browser:

Chrome
10.0 Mar 2011
Firefox
4.0 Mar 2011
IE/Edge
13.0 Nov 2015
Opera
11.5 May 2011
Safari
7.0 Oct 2013

You may also like

 Back to <output>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides