Search code examples
htmlcsscss-shapes

How to use CSS to surround a number with a circle?


I would like to surround a number in a circle like in this image:

Number in Circle Image

Is this possible and how is it achieved?


Solution

  • Here's a demo on JSFiddle and a snippet:

    .numberCircle {
        border-radius: 50%;
        width: 36px;
        height: 36px;
        padding: 8px;
    
        background: #fff;
        border: 2px solid #666;
        color: #666;
        text-align: center;
    
        font: 32px Arial, sans-serif;
    }
    <div class="numberCircle">30</div>

    My answer is a good starting point, some of the other answers provide flexibility for different situations. If you care about IE8, look at the old version of my answer.