bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Advanced Styling
CSS•Advanced Styling

CSS Rounded Corners

The CSS border-radius property is used to create rounded corners for elements.

CSS border-radius Property

The border-radius property defines the radius of an element's corners.

This property can be applied to all elements with a background-color , a border , or a background-image .

Here are three examples

  1. Rounded corners for an element with a background color:

Rounded corners!

  1. Rounded corners for an element with a border:

Rounded corners!

  1. Rounded corners for an element with a background image:

Rounded corners!

Example

Formatted code
#div1 {
  border-radius: 25px;
  background-color: #73AD21;
  padding: 20px;
  width: 200px;
  height: 150px;
}
#div2 {
  border-radius: 25px;
  border: 2px solid #73AD21;
  padding: 20px;
  width: 200px;
  height: 150px;
}
#div3 {
  border-radius: 25px;
  background-image: url(paper.gif);
  background-position: left top;
  background-repeat: repeat;
  padding: 20px;
  width: 200px;
  height: 150px;
}

Live preview

Tip

The border-radius property is actually a shorthand property for the border-top-left-radius , border-top-right-radius , border-bottom-right-radius and border-bottom-left-radius properties.

CSS border-radius - Specify Each Corner

The border-radius property can have from one to four values. Here are the rules:

Four values - border-radius: 15px 50px 30px 5px; (first value applies to top-left corner, second value applies to top-right corner, third value applies to bottom-right corner, and fourth value applies to bottom-left corner):

Three values - border-radius: 15px 50px 30px; (first value applies to top-left corner, second value applies to top-right and bottom-left corners, and third value applies to bottom-right corner):

Two values - border-radius: 15px 50px; (first value applies to top-left and bottom-right corners, and the second value applies to top-right and bottom-left corners):

One value - border-radius: 15px; (the value applies to all four corners, which are rounded equally:

Example

Formatted code
#div1 {
  border-radius: 15px 50px 30px 5px; /* four values */
  background: #04AA6D;
  width: 200px;
  height: 150px;
}
#div2 {
  border-radius: 15px 50px 30px; /* three values */
  background: #04AA6D;
  width: 200px;
  height: 150px;
}
#div3 {
  border-radius: 15px 50px; /* two values */
  background: #04AA6D;
  width: 200px;
  height: 150px;
}
#div4 {
  border-radius: 15px; /* one value */
  background: #04AA6D;
  width: 200px;
  height: 150px;
}

Live preview

CSS Elliptical and Circular Shapes

To create elliptical corners, you must specify two values for each radius, separated by a slash /. The first value defines the horizontal radius, and the second value defines the vertical radius.

To create a oval shape (for a rectangular element), or to create a circular shape (for a square element) set border-radius to 50%.

Example

Formatted code
#div1 {
  border-radius: 70px / 30px;
  background: #04AA6D;
  width: 200px;
  height: 150px;
}
#div2 {
  border-radius: 15px / 50px;
  background: #04AA6D;
  width: 200px;
  height: 150px;
}
#div3 {
  border-radius: 50%;
  background: #04AA6D;
  width: 200px;
  height: 150px;
}
#div4 {
  border-radius: 50%;
  background: #04AA6D;
  width: 200px;
  height: 200px;
}

Live preview

CSS Rounded Corners Properties

PropertyDescription
border-radiusA shorthand property for setting all the four border-*-*-radius properties
border-top-left-radiusDefines the shape of the border of the top-left corner
border-top-right-radiusDefines the shape of the border of the top-right corner
border-bottom-right-radiusDefines the shape of the border of the bottom-right corner
border-bottom-left-radiusDefines the shape of the border of the bottom-left corner

Chapter

Back to Advanced Styling

Next

Sass Tutorial

This chapter

Overview
53

Lessons

154m

Read time

1. CSS Rounded Corners2. Sass Tutorial3. CSS Border Images4. CSS Multiple Backgrounds5. CSS Background Size6. CSS Background Origin7. CSS Background Clip8. CSS Colors9. CSS Color Keywords10. CSS Gradients11. CSS Radial Gradients12. CSS Conic Gradients13. CSS Shadow Effects14. CSS Box Shadow15. CSS Text Effects16. CSS Custom Fonts17. CSS 2D Transforms18. CSS 2D Transform Scale19. CSS 2D Transform Skew / Matrix20. CSS 3D Transforms21. CSS Transitions22. CSS Transition Timing23. CSS Animations24. CSS Animation Timing25. CSS Animation Properties26. CSS Tooltip27. CSS Tooltip Arrows28. CSS Styling Images29. CSS Image Effects30. CSS Image Hover Overlays31. CSS Responsive Modal Images32. CSS Centering Images33. CSS Image Filter Effects34. CSS Image Shapes35. CSS object-fit Property36. CSS object-position Property37. CSS Masking38. CSS Gradient Mask Layers39. CSS SVG Mask Layers40. CSS Styling Buttons41. CSS Button Hover Effects42. CSS Button Groups43. CSS Pagination Styles44. CSS Multiple Columns45. CSS Column Rules46. CSS User Interface47. CSS Variables - var() Function48. CSS Overriding Variables49. CSS Variables and JavaScript50. CSS Variables in Media Queries51. CSS @property Rule52. CSS Box Sizing53. CSS Media Queries

On this page

CSS border-radius PropertyCSS border-radius - Specify Each CornerCSS Elliptical and Circular ShapesCSS Rounded Corners Properties