How to Round the Corners of an Element with border-radius in CSS
border-radius rounds the corners of an element. A small value softens them, a bigger value makes a pill, and 50% on a square makes a circle.
Syntax
<selector> {
border-radius: <radius>;
}
| Part | What it does |
|---|---|
<selector> | The element to round. |
<radius> | How round the corners are, such as 4px. Four values set the corners one by one, starting at the top left and going clockwise. |
MDN's border-radius page shows every form of the value, including elliptical corners.
The Example
The example is three blue bars: one with square corners, one with border-radius: 4px and one with border-radius: 16px.
Step 1: Write the Code
Create a file named index.html in a text editor, such as Visual Studio Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Border radius</title>
<style>
p {
background: #0f6cbd;
color: #ffffff;
padding: 8px;
}
.small {
border-radius: 4px;
}
.large {
border-radius: 16px;
}
</style>
</head>
<body>
<p>Square corners</p>
<p class="small">border-radius: 4px</p>
<p class="large">border-radius: 16px</p>
</body>
</html>
Step 2: Open It in a Browser
Double-click index.html. It opens in your browser:

The screenshot comes from Chromium 159, the open-source browser that Chrome is built on.
What Happened
- The corners have radii of
0px,4pxand16px. The first bar has no rule, and0is the default. - The 16-pixel corners look like round ends, because the bar is about as tall as two radii.
- The background follows the rounded corners, so the blue is cut off at each curve.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Rounding an element with no background or border | Nothing visible changes: a paragraph with border-radius: 16px and no background looked exactly the same | Give it a background or a border |
Expecting 50% to make a circle on any element | On a box that isn't square, it makes an oval: a 160 by 60 box became an ellipse | Make the box square first |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The corners look square | The element has no background or border to show the curve | Add a background or a border |
| A circle comes out as an oval | The width and height differ | Give it the same width and height |
FAQ
How do I make a circle?
Give a square box border-radius: 50%. A 60 by 60 box with a blue background became a blue circle.
How do I round only one corner?
Use four values, top left first, going clockwise: border-radius: 16px 0 0 0 rounded only the top-left corner, and left the other three at 0px.
Conclusion
Set border-radius to round an element's corners: a few pixels for soft corners, half the height for round ends, and 50% on a square for a circle.
Additional Resources
- border-radius, on MDN.
