HTML <output> style Attribute

A style attribute on an <output> tag assigns a unique style to the element.

Its value is CSS that defines the appearance of the output element.



A style attribute on an <output> tag.
Move the slider to see the output values 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"
          style="background-color:#4238ca; color:#fff;padding:8px 15px;margin:5px;border-radius:10px;">25</output>

Using style

The style attribute specifies the style, i.e. look and feel, of the <output> element.

A style contains any number of CSS property/value pairs, separated by semicolons (;).

The style attribute overrides any other style that was defined in a <style> tag or an external CSS file.

This inline styling affects the current <output> element only.


<output style="CSS-styles">



Value Description
CSS-styles One or more CSS property/value pairs separated by semicolons (;).

More Examples

A style attribute on an <output> tag.
Clicking the button toggles the background color of the <output> element.

The value is 25

<form oninput="display.value = range.value">
  <input type="range" id="range" value="25"> 

  <br /><br />
  The value is 
  <output id="myoutput" name="display" for="range"
          style="background-color:indigo; color:#fff;padding:8px 15px;margin:5px;border-radius:10px;">

<br />
<button onclick="toggle();">Toggle style</button>

  let toggle = () => {
    let element = document.getElementById("myoutput");

    if ( === "teal") { = "indigo";
    } else { = "teal";

Code explanation

The style attribute assigns a background color to the <output> element.

Clicking the button calls JavaScript which toggles the background color to another color.

Browser support

Here is when style support started for each browser:

10.0 Mar 2011
4.0 Mar 2011
13.0 Nov 2015
11.0 Dec 2010
5.1 Oct 2011

You may also like

 Back to <output>

Last updated on Sep 30, 2023