How to Make Rounded Corner Using CSS?

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

Overview

CSS is all about making our HTML documents aesthetically pleasing. While developing a web page, there might be instances where we want some elements or images to have rounded corners. Here, the CSS border-radius property comes into play.

  • We can use the border-radius property to add CSS rounded corners to any element.
  • We may often refer to the rounded borders as "friendly rectangles" because they imply comfort, security, and reliability, all of which enhance our user experience.
  • To add CSS rounded corners to an element, image, or border, we can use the border-radius property and specify the radius value in pixels, percentage, or em.
  • The border-radius property can have one to four values.
  • We can independently specify the border-radius for each corner by using the constituent properties like border-top-left radius, border-bottom-right radius, etc.
  • We can also use the border-radius property to create elliptical borders.

This article will help us understand how to use border-radius property to give an element CSS rounded corners.

Pre-requisites

Make sure you understand the fundamental ideas of border property before continuing.

Syntax

The CSS border-radius property is a shorthand property that rounds all the corners of the element uniformly. We can specify the border-radius in pixels or percentages.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

The Possible Values for Rounded Corners

ValueDescriptionExample
lengthWe can use the length values to indicate the radius.border-radius : 10px ;
percentageWe can use percentage values to indicate the radius.border-radius: 5% ;

Negative values are invalid .

Standard

For different browsers, including Chrome and Firefox, we may define the CSS rounded corners using the border-radius property by prefixing the property with -webkit and -moz. "-webKit" and "-moz" are vendor prefixes in CSS offered by Chrome and Firefox rendering engines, respectively. These prefixes enable us to use the CSS features without introducing inconsistencies.

StandardMozilla EquivalentWebkit Equivalent
border-radius: 10px;-moz-border-radius: 10px;-webkit-border-radius: 10px;

We only need the standardized version since all the browsers support the official CSS syntax. It is not essential, but we may prefix the property with "-webKit" and "-moz" to allow complete legacy browser support.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Individual Corners

The border-radius property is a shorthand property that defines the radius for all the corners of the element. We can independently specify the border radius for each corner by using the following constituent properties :

Constituent PropertyMozilla EquivalentWebkit EquivalentDescriptionExample
border-top-left-radius-moz-border-radius-topleft-webkit-border-top-left-radiusRounds the top-left corner of an element.border-top-left-radius : 10px ;
border-top-right-radius-moz-border-radius-topright-webkit-border-top-right-radiusRounds the top-right corner of an element.border-top-right-radius : 10px ;
border-bottom-right-radius-moz-border-radius-bottomright-webkit-border-bottom-right-radiusRounds the bottom-left corner of an element.border-bottom-right-radius:10px;
border-bottom-left-radius-moz-border-radius-bottomleft-webkit-border-bottom-left-radiusRounds the bottom-right corner of an element.border-bottom-left-radius:10px;

Shorthand Property

  • We can specify a single value if we want to round the corners uniformly.
  • We can specify two values. The first value sets the top-left and bottom-right corners, while the other applies to the top-right and bottom-left corners.
  • We can specify three values. The first value applies to the top-left corner, the second value applies to the top-right and bottom-left corners, and the third value applies to the bottom-right corner.
  • We can even specify four values. The first value applies to the top-left corner, the second value applies to the top-right corner, the third value applies to the bottom-right corner, and the fourth value applies to the bottom-left corner.
  • The shorthand property for the Mozilla equivalent is as follows :

Elliptical Rounding

There may be situations in which we prefer elliptical corners over completely symmetrical ones. We can specify the horizontal and vertical radiuses with a slash in between to create such corners.

SYNTAX

Example

  • A single pair of values for both the horizontal and vertical radiuses rounds all four corners.
  • If we want a more complex shape, we can use four values each for horizontal and vertical radiuses. Example
  • The constituent properties remain the same for elliptical rounding. We can specify the border radius for each corner individually using space-separated values instead of slash-separated ones. Example

Elliptical Rounding (Firefox 3.5+)

SYNTAX

We need the -moz-prefix since Mozilla Firefox 3.5 only allowed round corners. However, more recent versions of Firefox also enable elliptical corners.

This syntax also applies to the other constituent properties.

Example

Elliptical Rounding Shorthand (Firefox 3.5+)

  • A single pair of values for both the horizontal and vertical radiuses rounds all four corners.
  • We can even specify four values each for horizontal and vertical radiuses. These values represent the top-left, top-right,bottom-right, and bottom-left corners.

WebKit Elliptical Rounding

  • All corners Browsers like Chrome and Safari support WebKit elliptical rounding. We can use the following shorthand property to elliptically round all the corners.

    SYNTAX

    Example

  • Right corners only To elliptically round the right corners of the elements, we will use the following syntax : SYNTAX

    Example

Using the following examples, let's learn how to add rounded corners to elements:

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Examples

Example 1: This Example Describes the Border-Radius Property to Create Css Rounded Corners

HTML

CSS

Output

css-rounded-corners

Example 2: This Example Describes the Use of The Border-Bottom-Left-Radius Property

HTML

CSS

Output border-bottom-left-radius-property

Example 3: This Example Describes the Use of The Border-Top-Right-Radius Property

HTML

CSS

Output

border-top-right-radius-property

Example 4: This Example Describes the Use of The Border-Bottom-Right-Radius Property

HTML

CSS

Output

border-bottom-right-radius-property

Example 5: This Example Describes the Use of The Border-Top-Left-Radius Property

HTML

CSS

Output

border-top-left-radius-property

Example 6 : This Example Describes the Use of Shorthand Properties

HTML

CSS

Output example-use-of-shorthand-properties

Example 7 : We Can Learn how To Add Elliptical Corners with The Help of This Example

HTML

CSS

Output

add-elliptical-corners

Conclusion

  • We can use the border-radius property to add CSS rounded corners to any element.
  • We can specify the border-radius in pixels or percentages.
  • We can independently specify the border radius for each corner by using the constituent properties.
  • We can also use the border-radius property to create elliptical borders.
  • It is not essential, but we may prefix the property with "-webKit" and "-moz" to allow complete legacy browser support.
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more