HTML <progress> style Attribute

The style attribute on a <progress> tag assigns a unique style to the progress element. A style contains one or more CSS property/value pairs that define the appearance of the progress element.

Example

#

A style attribute on a <progress> element.

Re-indexing...

30%
<div>Re-indexing... </div>

<br />
<progress style="width:200px; height:20px;" value="30" max="100"> 30% </progress>

Using style

The style attribute specifies the style, i.e. look and feel, of the <progress> 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 <progress> element only.


Syntax

<progress style="CSS-styles">

Values

#

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

More Examples

A style attribute on a <progress> element.
Clicking the button toggles the width of the element.

Awaiting approval...

35%
<div>Awaiting approval... </div>

<br />
<progress id="myprogress" style="width: 100px; height: 20px;" 
          value="35" max="100"> 35% </progress>

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

<script>
  let toggle = () => {
    let element = document.getElementById("myprogress");

    if (element.style.width === "100px") {
       element.style.width = "200px";
    } else {
       element.style.width = "100px";
    }
  }
</script>

Code explanation

The style attribute assigns a width to the <progress> element.

Clicking the button calls JavaScript which changes the element width.


Browser support

Here is when style support started for each browser:

Chrome
8.0 Dec 2010
Firefox
16.0 Oct 2012
IE/Edge
10.0 Sep 2012
Opera
11.0 Dec 2010
Safari
6.0 Jul 2012

You may also like

 Back to <progress>
Guides