Write CSS to create a circle and a pill-shaped button
Description: Create a red circle of 100px and a green button with fully rounded sides.
Hint:
- A circle needs equal width and height with
border-radius: 50%. - Use a big value like
999pxfor a pill shape.
CSS circle and pill button
<style>
.circle {
width: 100px;
height: 100px;
border-radius: 50%;
background: #e53935;
}
.pill {
display: inline-block;
padding: 10px 28px;
border-radius: 999px;
background: #43a047;
color: white;
}
</style>
<div class="circle"></div>
<span class="pill">Pill button</span>
Output in the browser:
Output in the browser
Pill button
How it works
50%rounds each corner by half of the side, so a square becomes a circle.- A very big radius on a wide box rounds the short sides fully, which gives a pill.
Read Rounded Corners in CSS.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Borders |
| Rounded Corners in CSS |
| CSS Height and Width |
| CSS Padding |
| CSS Margins |
| CSS Box Model |
| CSS Outline |
| Exercises & Assignments |
|---|
| Write CSS to create a box with border, padding and rounded corners |
| Write CSS to create a circle and a pill-shaped button |
| Write CSS to style a login form |
| Interview Questions & Answers |
|---|
| What is the CSS box model? |
| What is the difference between margin and padding in CSS? |
| What is box-sizing: border-box in CSS? |