Horje
How to create empty circle with CSS ?

In this article, we will see how to create an empty circle. To create the empty circle, we will use HTML and CSS. HTML is used to create the basic structure and CSS is used here to make the circle.

Syntax:

element {
    ...
    border: 1px solid color;
    border-radius: 50%;
}

Approach: First we will create a div element and then add CSS styles to that element. We will set the width, height, border, and border-radius of the element. To create the circle, we will use the border-radius: 50%.

 

Example 1: In this example, we will create an empty circle.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" 
          content="IE=edge">
    <meta name="viewport" 
          content="width=device-width, 
                   initial-scale=1.0">
    <title>
        How to create empty circle with CSS?
    </title>

    <style>
        body {
            text-align: center;
        }
        
        h1 {
            color: green;
        }
        
        .circle {
            width: 200px;
            height: 200px;
            border: 1px solid black;
            border-radius: 50%;
            margin: auto;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h3>
        How to create empty circle with CSS?
    </h3>
    <div class="circle"></div>
</body>

</html>

Output:

 

Example 2: In this example, we will create an empty circle with a green background color.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" 
          content="IE=edge">
    <meta name="viewport" 
          content="width=device-width, 
                   initial-scale=1.0">
    <title>
        How to create empty circle with CSS?
    </title>

    <style>
        body {
            text-align: center;
        }
        
        h1 {
            color: green;
        }
        
        .circle {
            width: 200px;
            height: 200px;
            background-color: green;
            border-radius: 50%;
            margin: auto;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h3>
        How to create empty circle with CSS?
    </h3>
    <div class="circle"></div>
</body>

</html>

Output:

 




Reffered: https://www.geeksforgeeks.org


CSS

Related
Multiple Pendulum Animation using CSS Multiple Pendulum Animation using CSS
How to wrap an element with more content in flexbox container to have the same width as other elements in CSS ? How to wrap an element with more content in flexbox container to have the same width as other elements in CSS ?
How display: inline is different from display: inline-block in CSS ? How display: inline is different from display: inline-block in CSS ?
How to Center a Div using CSS ? How to Center a Div using CSS ?
How to use :before or :after pseudo-element to an input field in CSS ? How to use :before or :after pseudo-element to an input field in CSS ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
11