Skip to content

Instantly share code, notes, and snippets.

@haythamnikolaidis
Last active August 18, 2025 12:37
Show Gist options
  • Select an option

  • Save haythamnikolaidis/b42376a2026799d637bea4f56e83322c to your computer and use it in GitHub Desktop.

Select an option

Save haythamnikolaidis/b42376a2026799d637bea4f56e83322c to your computer and use it in GitHub Desktop.
CSS-only progress bar. No JavaScript needed. Dynamically updates using data attributes.
<html>
<head>
<meta charset="utf-8">
<title>Javascript-less Progress bar</title>
<style type="text/css" media="all">
.progress-bar{
background-color: #c0c0c0;
width: 100%;
height: 2rem;
}
.progress-bar::after{
display: block;
background-color: green;
height: 2em;
width: calc(attr(data-value type(<number>)) / attr(data-max type(<number>)) * 100%);
content: '';
}
</style>
</head>
<body>
<div class="progress-bar" data-value=50 data-max=150></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment