-2

I am a graphic designer and new to coding.

Can someone let me know how do I put a number inside a circle in pure HTML? I am putting it inside a table.

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103

4 Answers4

0

First, create your Circle in CSS..

#circle {
      width: 100px;
      height: 100px;
      background-image: linear-gradient(to right, rgb(38, 165, 166) 0%, rgb(124, 26, 94) 100%);
      border-radius: 50%
    }
  

This will be shown in a HTML container with id circle ..

<div id="circle"></div>

Inside this DIV you can put whatever number you like..

<div id="circle">69</div>

It might not align properly, so you cann modify the CSS to play.

text-align: center;

Example

Good luck with your learning, but you should show some effort when asking a question too.

EDIT//

For your pure HTML version.. You can just add the CSS to inline..

<div style="width: 100px;
      height: 100px;
      background-image: linear-gradient(to right, rgb(38, 165, 166) 0%, rgb(124, 26, 94) 100%);
      border-radius: 50%;
      text-align: center;"><h1>
69
</h1>
</div>
Pogrindis
  • 7,755
  • 5
  • 31
  • 44
  • Thanks a lot for the help. Is it possible to do this with just pure HTML without CSS? Can you let me know what do you mean "show some effort when asking question"? So next time I'll know what to do. Thanks! – foreverlearner4 Jan 04 '21 at 16:35
  • hmm not really.. Maybe an SVG element in html could be drawn.. but why torture yourself ? – Pogrindis Jan 04 '21 at 16:37
  • @foreverlearner4 I updated with a html only.. – Pogrindis Jan 04 '21 at 16:48
0

Using CSS background-radius property set to 50%.

An example:

.encircled {
  display: inline-block;
  padding: 1em;
  text-align: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: orange;
  border: 5px solid black;
}
<div class="encircled">42</div>
Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103
0

You need to use HTML with CSS.

Below is the CSS Code:

 .circle{
      border: 1px solid black;
      border-radius: 50%;
      height: 50px;
      width: 50px;
      text-align: center;
      justify-content: center;
      position: relative;
    }

HTML code should be:

<div class="circle">

    <p>1</p>

 </div>

.circle{
  border: 1px solid black;
  border-radius: 50%;
  height: 50px;
  width: 50px;
  text-align: center;
  justify-content: center;
  position: relative;
}
<div class="circle">

<p>1</p>

</div>
Rajen Trivedi
  • 1,225
  • 2
  • 5
  • 10
0

Actually Table in HTML can be inflexible so there many ways you can write your code to suit your needs, but this is an idea behind it. HTML

<ul>
    <li><span>1</span>First Element</li>
    <li><span>2</span>Second Element</li>
</ul>

CSS

li>span {
  display: inline-block;
  padding: 5px;
  border: 2px solid black;  /* black border */
  border-radius: 50%;   /* for round enclosing border */
}

This should work and editable. Comment for further notice.

Ahmad Khidir
  • 140
  • 1
  • 9