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.
A class attribute styling a <progress> element.
<style>
.progress-class {width: 200px;height: 20px;}
</style>
<div>Loading files... </div>
<progress class="progress-class" value="50" max="100"> 50% </progress>
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.
<progress class="classnames">
Value | Description |
---|---|
classnames | One or more space-separated class names. |
A class attribute styling a <progress> element.
Clicking the button toggles a classname that changes the width.
<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>
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>.
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 |
Back to <progress>