How to create a Pie Chart using HTML & CSS ? Last Updated : 28 Jun, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report A Pie Chart is a circular graph that shows data as percentages of a whole, with each slice representing a category. For example, Education 40%, Healthcare 30%, Transportation 20%, and Others 10%. It’s ideal for visualizing and comparing parts of a whole in a clear, simple way.Pie Chart using HTML CSS and JavascriptIf you want to learn Web Development checl out our Tutorial - Web DevelopmentStep by Step guide on How to create a Pie ChartStep 1: Define a <div> element with a class name to represent the pie chart container.Step 2: Set the width, height, and border-radius properties to create a circular shape for the pie chart.Step 3: Use the conic-gradient() function in the CSS background-image property to define the colors and angles for each segment of the pie chart.Step 4: Specify the colors and angles for each segment of the pie chart within the conic-gradient() function.Step 5: Adjust the colors, angles, and dimensions as needed to customize the appearance of the pie chart according to the data being represented.Example: In this example, we will design a pie chart using HTML and CSS. index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Pie Chart</title> <style> .piechart { width: 200px; height: 200px; border-radius: 50%; background-image: conic-gradient( pink 70deg, lightblue 0 235deg, orange 0 ); } </style> </head> <body> <h3>Pie Chart</h3> <div class="piechart"></div> </body> </html> OutputPie Chart using HTML & CSS Example outputExample 2: In this example, we will design Advanced Pie chart using HTML and CSS. index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Pie Chart with HTML & CSS</title> <style> body { font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; padding: 50px; background: #f0f0f0; } .chart-container { position: relative; width: 250px; height: 250px; border-radius: 50%; background: conic-gradient( #4CAF50 0% 60%, /* Chrome */ #2196F3 60% 80%, /* Firefox */ #FFC107 80% 90%, /* Edge */ #9C27B0 90% 100% /* Safari */ ); box-shadow: 0 0 15px rgba(0,0,0,0.2); } .center-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; width: 100px; height: 100px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 18px; box-shadow: inset 0 0 10px rgba(0,0,0,0.1); } .legend { margin-top: 30px; display: flex; flex-direction: column; gap: 10px; } .legend-item { display: flex; align-items: center; gap: 10px; } .legend-color { width: 20px; height: 20px; border-radius: 4px; } .chrome { background: #4CAF50; } .firefox { background: #2196F3; } .edge { background: #FFC107; } .safari { background: #9C27B0; } </style> </head> <body> <h2>Web Browser Usage</h2> <div class="chart-container"> <div class="center-label">100%</div> </div> <div class="legend"> <div class="legend-item"><div class="legend-color chrome"></div> Chrome - 60%</div> <div class="legend-item"><div class="legend-color firefox"></div> Firefox - 20%</div> <div class="legend-item"><div class="legend-color edge"></div> Edge - 10%</div> <div class="legend-item"><div class="legend-color safari"></div> Safari - 10%</div> </div> </body> </html> Outputoutput Comment More infoAdvertise with us Next Article How to create a Line Chart With CSS ? N nehaahlawat Follow Improve Article Tags : Technical Scripter Web Technologies Write From Home Web Templates Similar Reads How to create a progress bar using HTML and CSS? 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 progr 1 min read How to create an Area Chart using CSS ? In this article, we will see how to create Area charts using CSS. There are many Libraries available, which can help us to build area charts, although, here, we will be using pure HTML and CSS to create an Area Chart. An Area Chart is a graphical representation of quantitative data where multiple da 4 min read How to create a Line Chart With CSS ? The Chart is a pictorial or graphical representation of the data visualization, based on certain conditions There are various types of charts available such as Bar Charts, Line Charts, Pie Charts, etc, that are used to represent important data. In this article, we will see how to create the Line cha 6 min read How to Create Badges using HTML and CSS ? This article will show you how to create a badge using HTML and CSS. Badges are simple and basic components that are used to display an indicator or count a number. This is quite useful for mail count and alerting purposes, among other things. Badges are identical to labels, with the exception that 2 min read How to Draw a Semi-Circle using HTML and CSS ? To draw a semi-circle using HTML and CSS, Use the 'border-radius' property in combination with a square-shaped container div. Set border-radius to create a circular shape, and then use additional CSS to clip one half, forming a semi-circle. Approach:First create a HTML structure, specifying language 1 min read How to implement bar and pie charts using Chart.js ? In this article, we will learn to implement basic bar graphs and pie charts using the Chart JS CDN library.Approach:In the HTML design, use the <canvas> tag for showing the bar or pie chart graph.In the script part of the code, instantiate the ChartJS object by setting the type, data and optio 2 min read Like