Web Development Course:
HTML Progress Bar: Main Tips
- Introduced in HTML5,
progresselement represents a certain ongoing task and might indicate its level of completion.
- It works in a similar fashion to the HTML gauge.
- HTML progress bars can be determinate or indeterminate.
- The ending tag cannot be omitted.
- You can easily style the progress bar with Bootstrap.
Tracking HTML Progress
progress tags are used to specify an HTML progress bar:
<p>Donuts eaten:</p> <progress value="60" max="100"></progress>
Possible progress Tag Attributes
There are two optional attributes you can use with HTML5 progress bars:
max attribute specifies total work required by the task. It must have a positive value (the default value is 1):
<p>Ice cream devoured:</p> <progress value="10" max="50"></progress>
value attribute specifies how much of the task is completed. It must have a positive value that does not exceed
max (or 1, if
max is not specified):
<p>Slushies slurped:</p> <progress value="30" max="100"></progress>
Determinate or Not?
In the example below, you can see two HTML5 progress bars:
<p>Fridge emptied:</p> <progress value="30" max="100"></progress> <p>Belly filled:</p> <progress max="100"></progress>
The first one is determinate: it has the
value specified and therefore shows the level of completion of the task.
The second bar has no
value defined, which makes it indeterminate. That means it will only indicate that the action is still happening. However, it will not represent what part of it is completed and how much is still left to do.