Alex Rivera | Logout

How to draw circle in html page?

Asked 2011-08-03T04:53:57.577
142

How do you draw a circle using HTML5 and CSS3?

Is it also possible to put text inside?

Edit
Report

1 Answer

4

You can use the border-radius attribute to give it a border-radius equivalent to the element's border-radius. For example:

<div style="border-radius 10px; -moz-border-radius 10px; -webkit-border-radius 10px; width: 20px; height: 20px; background: red; border: solid black 1px;">&nbsp;</div>

(The reason for using the -moz and -webkit extensions is to support pre-CSS3-final versions of Gecko and Webkit.)

There are more examples on this page. As far as inserting text, you can do it but you have to be mindful of the positioning, as most browsers' box padding model still uses the outer square.

answered 2011-08-03T04:59:49.347

Your Answer