Open In App
Related Articles

How to create a progress bar using HTML and CSS?

Improve Article
Improve
Save Article
Save
Like Article
Like

The progress bar is an important element in the web, the progress bar can be used for downloading, marks obtained, skill measuring unit, etc. To create a progress bar we can use HTML and CSS. To make that progress bar responsive you will need JavaScript.

In this article, we will learn to create progress bars using HTML and CSS. A progress bar is created by using two HTML “div”, the container (parent div), and the skill (child div) as shown in the following examples.

Example 1: We will divide the article into two coding sections, in the first section we will work on HTML, and in the second section will design that progress bar.

  • HTML Code: We create a parent div that will define the full length unit and the child div will define the obtain unit.




    <!DOCTYPE html>
    <html>
    <head>
        <title>Design a Progress bar</title>
    </head>
    <body>
        <h1>My Skills</h1>
        <p>HTML</p>
        <div class="container">
            <div class="skill html">80%</div>
        </div>
      
        <p>PHP</p>
        <div class="container">
            <div class="skill php">60%</div>
        </div>
    </body>
      
    </html>

  • CSS Code: By using CSS we will decorate both the div, colored the full and obtain unit. Set the length of the divs also.




    <style>
        p {
            font-size: 20px;
        }
      
        .container {
            background-color: rgb(192, 192, 192);
            width: 80%;
            border-radius: 15px;
        }
      
        .skill {
            background-color: rgb(116, 194, 92);
            color: white;
            padding: 1%;
            text-align: right;
            font-size: 20px;
            border-radius: 15px;
        }
      
        .html {
            width: 80%;
        }
      
        .php {
            width: 60%;
        }
    </style>

Final Code: Here we will combine the above two coding section.




<!DOCTYPE html>
<html>
<head>
    <style>
        p {
            font-size: 20px;
        }
      
        .container {
            background-color: rgb(192, 192, 192);
            width: 80%;
                border-radius: 15px;
        }
      
        .skill {
            background-color: rgb(116, 194, 92);
            color: white;
            padding: 1%;
            text-align: right;
            font-size: 20px;
                border-radius: 15px;
        }
      
        .html {
            width: 80%;
        }
      
        .php {
            width: 60%;
        }
    </style>
</head>
<body>
    <h1>My Skills</h1>
    <p>HTML</p>
    <div class="container">
        <div class="skill html">80%</div>
    </div>
  
    <p>PHP</p>
    <div class="container">
        <div class="skill php">60%</div>
    </div>
</body>
</html>

Output:


Last Updated : 22 Jul, 2020
Like Article
Save Article
Similar Reads
Related Tutorials