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 <progress> class Attribute

The class attribute assigns one or more classnames to the <progress> tag.

Classnames are defined in a stylesheet or in a local <style> element.

Classes, i.e. classnames, are used to style elements.

Example

#

A class attribute styling a <progress> element.

Loading files...
50%
<style>
  .progress-class {width: 200px;height: 20px;}
</style>

<div>Loading files... </div>
<progress class="progress-class" value="50" max="100"> 50% </progress>

Using class

Classes (i.e. classnames) are used for styling the progress element.

Multiple classnames are separated by a space.

JavaScript uses classes to access elements by classname.

Tip:  class is a global attribute that can be applied to any HTML element.


Syntax

<progress class="classnames">

Values

#

Value Description
classnames One or more space-separated class names.

More Examples

A class attribute styling a <progress> element.
Clicking the button toggles a classname that changes the width.

Loading files...
50%
<style>
  .progress-sm { width: 100px;height: 20px; }
  .progress-lg { width: 200px; }
</style>

<div>Loading files... </div>
<progress id="myprogress" class="progress-sm" value="50" max="100"> 50% </progress>

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

<script>
  let toggle = () => {
    let element = document.getElementById("myprogress");
    element.classList.toggle("progress-lg");
  }
</script>

Code explanation

Two CSS classes are defined in the <style> element.

The class attribute in <progress> assigns one classname.

Repeatedly clicking the button adds and removes the second class, toggling the width of the <progress>.


Browser support

Here is when class 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>

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