
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create a Skill Bar with CSS
If you want to display a skill bar stating the proficiency of a skill, then create a skill bar. Let's say we are showing programming proficiency that a student is proficient in which programming language. Create a skill bar and display the proficiency in percentage with different colors for different skills. Let us see how to create a skill bar with CSS.
Create a container
Create a div container for each skill bar. We have shown only a single skill bar below −
<h3>Python</h3> <div class="container"> <div class="python">75%</div> </div>
Other skill bars are shown below −
<h3>Java</h3> <div class="container"> <div class="java">70%</div> </div> <h3>C++</h3> <div class="container"> <div class="cpp">60%</div> </div> <h3>C</h3> <div class="container"> <div class="c">40%</div> </div>
Style the div container
The div container for each skill bar is styled like this. The width is set to 100%
.container { width: 100%; background-color: rgb(231, 231, 231); border-radius: 20px; }
Individual skill bars styling
All the skill bars we have included on a web page are set with the bold font weight and the text is aligned to the center. To make it look like a bar, we have used the border-radius property −
.cpp, .java, .python, .c { text-align: center; font-weight: bolder; padding-top: 3px; padding-bottom: 3px; color: white; border-radius: 20px; }
Add the percentage value
For each skill bar, the percentage values are set using the width property. Also, different background colors are set using the background-color property −
.cpp { width: 90%; background-color: #4caf50; } .java { width: 80%; background-color: #2196f3; } .python { width: 65%; background-color: #f44336; } .c { width: 60%; background-color: #808080; }
Example
To create a skill bar with CSS, the code is as follows −
<!DOCTYPE html> <html> <head> <style> * { box-sizing: border-box; } body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } h1 { text-align: center; } .container { width: 100%; background-color: rgb(231, 231, 231); border-radius: 20px; } .cpp, .java, .python, .c { text-align: center; font-weight: bolder; padding-top: 3px; padding-bottom: 3px; color: white; border-radius: 20px; } .cpp { width: 90%; background-color: #4caf50; } .java { width: 80%; background-color: #2196f3; } .python { width: 65%; background-color: #f44336; } .c { width: 60%; background-color: #808080; } </style> </head> <body> <h1>Programming Proficiency</h1> <h3>Python</h3> <div class="container"> <div class="python">75%</div> </div> <h3>Java</h3> <div class="container"> <div class="java">70%</div> </div> <h3>C++</h3> <div class="container"> <div class="cpp">60%</div> </div> <h3>C</h3> <div class="container"> <div class="c">40%</div> </div> </body> </html>