Circular Progress Bar using HTML and CSS
Tags: html, javascript, beginners, webdev
Published: 2021-10-19 16:12:59

Circular Progress Bar is a popular web element that is mainly used on business or personal websites. If you want to create a circular progress bar using HTML and CSS, then this article will help you. Here I am going to show you how to make a simple CSS circle progress bar.

When you load the page, this animation will go from zero to your assigned meaning. A percentage of text is used here, but no animation is used in this text. It is made in a very simple way. 

✅ **Watch Live Preview** 👉👉  [Circular Progress Bar](https://www.foolishdeveloper.com/2021/09/circular-progress-bar-using-html-css.html) 

In this article, I will show you step by step how I made this circular progress bar design.To make it, you need to have an idea about basic HTML and CSS.

### Step 1: The basic structure of Circular Progress Bar
I have used HTML and CSS to create the basic structure of the Circular Progress Bar. I have created a small circle on the webpage.

The width and height of this circle are 150 px. The background color of the circle is white and margins are used to place it in the middle.
```html
<div class="circle-wrap">
  <div class="circle">
 
  </div>
</div>
```

```css
body {
  font-family: "Roboto", sans-serif;
  background:#d2eaf1;
}

.circle-wrap {
  margin: 150px auto;
  width: 150px;
  height: 150px;
  background: #fefcff;
  border-radius: 50%;
  border: 1px solid #cdcbd0;
}
```

![The basic structure of Circular Progress Bar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4skngoh6mu01aq3woav.jpg)


### Step 2: Half of the simple CSS circle progress bar
As I said before, the animation in this circle is divided into two parts. This means that the animation has been divided into two parts up to the customer value.

I have made the first part of those two parts. Width and height 150 have been used to make this animation equal in size to the Circular Progress Bar. Similarly, `border-radius 50%` has been used to make it round. 

Here I have set the background-color to blue. If you want to play an animation in another color, you can use that color here.
```html
<div class="mask half">
    <div class="fill"></div>
</div>
```

```css
.circle-wrap .circle .mask,
.circle-wrap .circle .fill {
  width: 150px;
  height: 150px;
  position: absolute;
  border-radius: 50%;
}
 
.mask .fill {
  clip: rect(0px, 75px, 150px, 0px);
  background-color: #227ded;
}
```
![Half of the simple CSS circle progress bar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3v5u3cfmktpzvox8vkbj.jpg)

### Step 3: The other half of the Circular Progress Bar
Now I have designed the other half of the Circular Progress Bar. I set the time to three seconds by adding animation here. This means that when this page is opened, the animation will take 3 seconds to reach the meaning you set from zero.

Here 135 degrees have been used using transform. This transform will determine where the animation will end in this circle. 


  ➤ We know that a circle is formed by 360. Since here we have divided the **[CSS circle progress bar](https://www.foolishdeveloper.com/2021/09/circular-progress-bar-using-html-css.html)** into two parts, so each part is 180 degrees. 

  ➤ Here we have set a `135-degree` animation for each part using Transform. So it will be `270 degrees` for the total circle. Here I want to increase the animation to 75% so I have used 270 degrees.

 > (360/100) * 75 = 270 

You determine the value of this degree according to your needs. For example, if you want the animation of the Circular Progress Bar will be up to 80%. But for that, you have to use `144 degrees here`. Lastly, I have implemented this animation using @keyframes. 

```html
<div class="mask full">
   <div class="fill"></div>
</div>
```


```css
.circle-wrap .circle .mask {
  clip: rect(0px, 150px, 150px, 75px);
}
 
.mask.full,
.circle .fill {
  animation: fill ease-in-out 3s;
  transform: rotate(135deg);
}
  
@keyframes fill{
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(135deg);
  }
}
```
![The other half of the Circular Progress Bar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8q105trln1dtnyf1uhc.jpg)

### Step 4: Create a percentage in the Circular Progress Bar
Now I have added percentages in this [circular progress bar](https://www.foolishdeveloper.com/2021/09/circular-progress-bar-using-html-css.html). Although that percentage of animation is not added. 

Added text using basic HTML and CSS code. I have used `text-align: center` and position: absolute to place the text in the middle of the Circular Progress Bar.

 I used `border-radius: 50%` to make its background width and height 122 px and round. Here I have used `font-size: 2em` to make the size of the text smaller and larger.
```html
<div class="inside-circle"> 75% </div>
```


```css
.circle-wrap .inside-circle {
  width: 122px;
  height: 122px;
  border-radius: 50%;
  background: #d2eaf1;
  line-height: 120px;
  text-align: center;
  margin-top: 14px;
  margin-left: 14px;
  color: #1e51dc;
  position: absolute;
  z-index: 100;
  font-weight: 700;
  font-size: 2em;
}
```
![Circular Progress Bar using HTML and CSS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/akm0ix0uean3sbz4t88u.jpg)

**Related Post:**
1. [Responsive Footer HTML CSS](https://www.foolishdeveloper.com/2021/09/responsive-footer-design.html) 
2. [Todo List using JavaScript](https://www.foolishdeveloper.com/2021/11/todo-list-javascript.html)
3. [Simple Stopwatch using JavaScript](https://www.foolishdeveloper.com/2021/10/simple-stopwatch-using-javascript.html)
4. [Javascript Age Calculator](https://www.foolishdeveloper.com/2021/07/javascript-age-calculator.html)
5. [javaScript Password Generator](https://www.foolishdeveloper.com/2021/07/random-password-generator-javascript.html)
6. [Automatic Image Slider in Html CSS](https://www.foolishdeveloper.com/2021/07/automatic-image-slider.html) 
7. [Sidebar Menu Using HTML CSS](https://www.foolishdeveloper.com/2021/06/sidebar-menu-using-html-css-javascript.html) 

 As you can see in the picture above, now this CSS Circular Progress Bar is absolutely ready. Hope you find out from this article how I created this **Circular Progress Bar using HTML and CSS**.

You can visit my blog for more tutorials like this. 😊
https://www.foolishdeveloper.com/