All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

How To Make A Circle In HTML And CSS

Last Updated : Mar 11, 2024

How To Make A Circle In HTML And CSS

In this tutorial we will show you the solution of how to make a circle in HTML and CSS, as we know css used to style html elements, here we used internal style method to show demo.

We can create circle shape in html and css by using many methods here we will see about circle created by using css style property of ‘border-radius’ and also we can make circle by ‘clip-path’ style property but we don’t have inbuilt method to make any shapes in html.

Step By Step Guide On How To Make A Circle In HTML And CSS :-

We can implement styles using three types (i.e inline,external or internal) Internal means we have to define our style within <style> tag in head block and inline means we have use style within element definition, external means we defined our css at separate file with .css extension we have to import by <link> tag within head block.

In our program we defined <div> tag with attribute of class with value ‘cir’. Using that we defined some block of styles with property ‘border-radius’ to make circle shape.

<!DOCTYPE html>
<html>
    <head>
        <title>CSS CIRCLE</title>
        <style>
            .cir{
                width: 100px;
                height:100px;
                border-radius: 50%;
                background-color: rgb(7, 76, 252);
                position: absolute;
            }
        </style>
    </head>
    <body>
        <div class="cir"></div>
    </body>
</html>
  1. <!DOCTYPE html> tag which is instruct the web browser about what version of HTML file written in.
  2. The<html> tag is used to indicate the beginning of HTML document.
  3. As above shown <head> tag is containing information about webpage and if you need any external file those links are declared here. <title> tag is used for set the webpage title.
  4. Within <style> tag we defined block of styles. Those are used to make circle shape, within that we sets circle width to ‘100px’ and height to ‘100px’ and border-radius to ‘50%’.
  5. When we given border radius to 50% it makes curve shape half of width and height of div so we finally gets circle shape too easily.
  6. After that we sets ‘background-color’ to ‘blue in rgb format’ and ‘position:absolute’ is must because empty of div showup on display. When we needs to fill them with text so it will showup but it is not properly make shape because lack of text width.
  7. Both <head> and <title> tags having their pair end tag, so we need to close the ending tags respectively. If you’re not closed anyone of ending tag properly that is also affect the webpage result.
  8. <body> tag is beginning of main coding part because it contain coding of entire website blocks and elements described here.
  9. Here <div> tag we defined with some class attribute ‘cir’ its styled by as we seen at point 4.
  10. Both </body>,</html> tags closed respectively. </body> tag indicates the end of body, Then </html> tag indicates the end of HTML document.

Conclusion :-

In conclusion we are able to know how to make circle shape in html and css.

When we load our program we can see normal size of circle with blue color and also we can make any size of circle with any background color.

This concept will useful when we needs to design our website or make any animations we needs to know aware of this and we can also make any shapes using css later will see about them.

I hope this tutorial on how to make a circle in HTML and CSS helps you and the steps and method mentioned above are easy to follow and implement.