CSS Border Radius
button {
border-radius: 4px;
}
.avatar {
border-radius: 50%;
}
Let me ask you something.
Have you ever noticed that almost no modern website uses perfectly sharp square corners anymore? Buttons are slightly rounded. Cards have soft edges. Profile pictures are perfect circles. Search bars are fully pill shaped.
That softness is not accidental. Rounded corners feel friendlier, more modern, and more approachable than sharp edges. And it is all done with one single CSS property — border-radius.
What is Border Radius
Border radius controls how rounded the corners of an element are. The higher the value the more rounded the corners become.
The button now has slightly rounded corners. Subtle but immediately softer than a sharp edged button.
Try increasing that value and watch what happens.
Now the button is fully pill shaped. The corners are so rounded they curve into each other creating that smooth oval look you see on a lot of modern buttons.
There is no single right amount of border radius. It depends on your design. A value of 4px to 8px feels professional and modern. Around 12px to 16px feels friendly and approachable. Full pill shape feels playful and bold. Match the border radius to the personality of what you are building.
Border Radius on Individual Corners
Just like padding and margin you can control each corner separately. The order goes top left, top right, bottom right, bottom left — clockwise starting from the top left.
Unlimited movies, TV shows, and more.
The top two corners are rounded and the bottom two are sharp. This is exactly the pattern used for modal windows and bottom sheets on mobile apps — rounded at the top, flat at the bottom where it meets the screen edge.
You can also use the individual properties.
.card {
border-top-left-radius: 16px;
border-top-right-radius: 16px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
Same result, more explicit. Use whichever feels cleaner to you.
Creating a Perfect Circle
Here is one of the most used tricks in CSS. If you have an element that is the same width and height — a perfect square — and you set border-radius to 50% it becomes a perfect circle.
A perfect red circle. This is exactly how profile pictures, avatars, and circular icons are made on every website and app you have ever used.
When using border-radius: 50% to create a circle the element must have equal width and height. If the
width and height are different you will get an oval instead of a circle. Always double check both dimensions are the
same.
Border Radius on Images
Border radius works on images too. This is how you get those rounded profile photos.
The image is now a perfect circle. That object-fit: cover makes sure the image fills the circular
space without stretching — we will cover object-fit in detail in its own lesson.
Using Percentage vs px
You can set border-radius using either px or percentage.
px gives you a fixed amount of rounding. border-radius: 8px always rounds by exactly 8
pixels no matter how big or small the element is.
% gives you rounding relative to the element size. border-radius: 50% always creates a
perfect circle or oval shape relative to the element dimensions.
For buttons and cards use px. For circles and avatars use 50%.
A value of border-radius: 999px is a trick a lot of developers use instead of 50% for pill shaped
buttons. It works because 999px is always larger than any reasonable button height so the browser just rounds the
corners as much as possible giving you a perfect pill shape without needing to know the exact dimensions.
Building the Netflix Clone
Let us round some corners on our Netflix clone. The buttons and the input field will feel much more modern with a little border radius.
Netflix
Unlimited movies, TV shows, and more.
Starts at USD 2.99. Cancel anytime.
Ready to watch? Enter your email to create or restart your membership.
* { margin: 0; padding: 0; } body { font-family: "Roboto", Arial, sans-serif; font-size: 16px; padding: 40px; background-image: linear-gradient(to bottom, rgba(0,0,0,0.7), rgba(0,0,0,0.4)), url("https://assets.nflxext.com/ffe/siteui/vlv3/9ba9f0e2-b246-47f4-bd1f-3e84c23a5db8/web/NP-en-20251020-TRIFECTA-perspective_774f89dc-b75d-4cfc-b1fe-52086741fae3_large.jpg"); background-size: cover; background-position: center; background-repeat: no-repeat; text-align: center; } #logo { font-family: "Bebas Neue", sans-serif; font-size: 3rem; font-weight: 700; color: #E50914; letter-spacing: 4px; line-height: 1; margin-bottom: 16px; } h1 { font-family: "Bebas Neue", sans-serif; font-size: 3rem; font-weight: 700; color: white; letter-spacing: 2px; line-height: 1.2; margin: 60px 0 16px 0; } p { font-size: 1.1rem; font-weight: 300; color: white; line-height: 1.6; margin-bottom: 12px; } button { background-color: #E50914; color: white; font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 2px; padding: 12px 32px; margin-top: 24px; border: none; border-radius: 4px; } .signin { background-color: transparent; border: 2px solid white; color: white; font-size: 0.9rem; font-weight: 600; padding: 8px 20px; margin-top: 0; border-radius: 4px; } input { border: 2px solid #cccccc; padding: 12px 16px; font-size: 1rem; border-radius: 4px; }Everything has a consistent 4px border radius now. The buttons feel modern and clickable. The input field matches. It is a small detail but it makes the whole thing feel more cohesive and designed.
Have anything to say about this lesson?
Your feedback helps improve these tutorials. If something was confusing or missing, let us know.