All TalkersCode Topics

Follow TalkersCode On Social Media

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

CSS Circle With Text

Last Updated : Mar 11, 2024

CSS Circle With Text

In this tutorial we will show you the solution of CSS circle with text, 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 ‘clip-path’ and also we can make circle by ‘border-radius’ style property but we don’t have inbuilt method to make any shapes in html.

Step By Step Guide On CSS Circle With Text :-

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’ and within that we defined para <p> tag with attribute class of ‘txt’, one text.

Using that we defined some block of styles with property ‘clip-path’ value ‘circle()’ to make circle shape.

In clip-path property we can make basic shapes like circle, ellipse, polygon and inset.

<!DOCTYPE html>
<html>
    <head>
        <title>CSS CIRCLE</title>
        <style>
            .cir{
                width: 30%;
                height: 30%;
                clip-path: circle();
                background-color: green;
                position: absolute;
            }
            .txt{
                margin-left: 45%;
            }
        </style>
    </head>
    <body>
        <div class="cir"><p class="txt">Circle</p></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 ‘30%’ and height to ‘30%’ and clip-path to ‘circle()’.
  5. Clip path property lets you clip an element to a basic shape or to an SVG source. Here we used to make circle of basic shape.
  6. After that we sets ‘background-color’ to ‘green’ 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. In class ‘.txt’ we defined ‘margin-left’ property to value ‘45%’ because it hidden by shape so we moved text from hidden area.
  8. 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.
  9. <body> tag is beginning of main coding part because it contain coding of entire website blocks and elements described here.
  10. Here <div> tag we defined with some class attribute ‘cir’ and also we puts ‘circle’ text on between <div> tag then its styled by as we seen at point 4.
  11. 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 with text on that in css.

When we load our program we can see normal size of circle with green color with circle text on that 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 CSS circle with text helps you and the steps and method mentioned above area easy to follow and implement.

Author Image About Pragati

Experienced coding content writer who enjoys breaking down complex concepts in programming languages like Java, Python, C, and C++. Over three years of experience producing interesting and relevant content for a variety of entities. Committed to providing concise and easy-to-understand articles that assist readers in easily understanding technology and industry trends in the world of coding and software development.

Follow Pragati On Linkedin 🡪