Border radius lets you make the corners of boxes round instead of sharp. It makes designs look softer and friendlier.
Border radius in CSS
Start learning this pattern below
Jump into concepts and practice - no test required
selector {
border-radius: value;
}The value can be in px, em, %, or other CSS units.
You can set one value for all corners or specify each corner separately.
button {
border-radius: 10px;
}div {
border-radius: 50%;
}.box { border-radius: 10px 20px 30px 40px; }
.card { border-top-left-radius: 15px; border-bottom-right-radius: 15px; }
This example shows a green square box with rounded corners using border-radius: 25px;. The box is centered and has white text inside. The corners are smoothly rounded, making the box look friendly and modern.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Border Radius Example</title> <style> .box { width: 150px; height: 150px; background-color: #4CAF50; border-radius: 25px; display: flex; align-items: center; justify-content: center; color: white; font-family: Arial, sans-serif; font-size: 1.25rem; margin: 2rem auto; box-shadow: 0 4px 6px rgba(0,0,0,0.1); } </style> </head> <body> <main> <section> <div class="box" role="region" aria-label="Green box with rounded corners"> Rounded Box </div> </section> </main> </body> </html>
Using percentages like 50% on a square makes a perfect circle.
You can combine border-radius with shadows and colors for nice effects.
Remember to check how rounded corners look on different screen sizes for good design.
Border radius makes corners round instead of sharp.
You can set one radius for all corners or different ones for each corner.
Rounded corners improve the look and feel of buttons, boxes, and images.
Practice
border-radius do to an element?Solution
Step 1: Understand the property purpose
Theborder-radiusproperty controls the roundness of the corners of an element.Step 2: Compare options with property effect
Only "It makes the corners of the element rounded instead of sharp." describes making corners rounded, which matchesborder-radius.Final Answer:
It makes the corners of the element rounded instead of sharp. -> Option AQuick Check:
border-radius = rounded corners [OK]
- Confusing border-radius with border color or thickness
- Thinking it adds shadows
- Assuming it changes element size
Solution
Step 1: Recall correct CSS syntax for border-radius
The property accepts one to four length values without commas. For all corners equal, one value is enough.Step 2: Check each option's syntax
border-radius: 10px; uses one value with unit and no commas, which is correct. border-radius: 10; lacks units, C has too many values, D uses commas which are invalid.Final Answer:
border-radius: 10px; -> Option DQuick Check:
One value with unit, no commas = correct syntax [OK]
- Omitting units like px
- Adding commas between values
- Using too many values
div {
width: 100px;
height: 100px;
background-color: blue;
border-radius: 50%;
}Solution
Step 1: Understand border-radius with percentage
Settingborder-radius: 50%on a square makes the corners fully rounded, forming a circle shape.Step 2: Analyze the div shape and color
The div is 100px by 100px, so a circle with 100px diameter and blue fill will appear.Final Answer:
A blue circle -> Option BQuick Check:
border-radius 50% on square = circle [OK]
- Thinking 50% means half-rounded corners only
- Confusing circle with rectangle
- Ignoring the shape dimensions
div {
border-radius-top-left: 15px;
}Solution
Step 1: Recall correct property for individual corner radius
The correct property to round the top-left corner isborder-top-left-radius.Step 2: Check the given property name
The snippet usesborder-radius-top-left, which is invalid CSS syntax.Final Answer:
Property name is incorrect; should be border-top-left-radius -> Option CQuick Check:
Individual corner radius = border-top-left-radius [OK]
- Swapping words in property name
- Forgetting units on values
- Thinking border-radius alone can target one corner
Solution
Step 1: Recall border-radius order for four values
The order is top-left, top-right, bottom-right, bottom-left.Step 2: Assign 20px to top-left and bottom-right, 0 to others
So values should be: 20px (top-left), 0 (top-right), 20px (bottom-right), 0 (bottom-left).Step 3: Match options with correct order
border-radius: 20px 0 0 20px; matches this order correctly.Final Answer:
border-radius: 20px 0 0 20px; -> Option AQuick Check:
Order: top-left, top-right, bottom-right, bottom-left [OK]
- Mixing up the order of values
- Using five values instead of four
- Assigning wrong corners to values
