Progress Bar with HTML and CSS
Create a Progress Bar using nested <div>
elements. Use CSS for design and the width
of the inner <div>
as the progress indicator. Here's the bare-bones code:
Modify the width
in the style
to smoothly illustrate progress.
Tailoring the bar to devices
To make your Progress Bar fit comfortably on devices of any size, media queries are a must. To maintain the same visual appeal regardless of the progression, the border-radius depends on the height.
Keep your progress bar's corners round and happy irrespective of how full it gets by adjusting the inner div's border-radius.
Child selectors are the way to go for precise element styling, giving your users an accurate visual guide.
Making the bar your own
HTML5 provides a nifty <progress>
element that simplifies the progress bar creation process and does away with the need for JavaScript. Just set max
and value
attributes for instant updates:
With some ::-webkit-progress-bar
and ::-moz-progress-bar
magic, you can make the <progress>
element dance to your tunes in Webkit and Mozilla browsers:
Visualising progress
Take a dip into the minimalist, graphical world of ASCII art, where every square is a chunk of progress. The better part is, this wall won’t keep anyone out:
There you have it: plenty of pumpkin progress to flesh out the abstract concept of loading completion.
Vibrant bar with panache
Customising your bar's output – whether textual or visual – is just a :after
pseudo-element away.
Going full width with margin: 0 auto;
makes for a snazzy, centered progress bar. Around the edges, padding keeps your content cute and cozy.
Ensuring uniform look across browsers
Nothing's worse than design discrepancies across browsers. Set up fallbacks for older browsers – especially for modern elements like <progress>
.
Was this article helpful?