CSS: Round Corners

By Xah Lee. Date: . Last updated: .

Use border-radius attribute to create round corners.

Here's a div element with round coners:

Round corners
div {
border:solid thin black;
border-radius:10px;
}

[see CSS: Border, Outline]

Examples

100px × 100px square.


border-radius:
0px

border-radius:
10px

border-radius:
20px

border-radius:
30px

border-radius:
40px

border-radius:
50px

If border-radius is more than half of the width or height (whichever is smaller), the whole thing becomes a circle.

border-radius:
60px

Rectangle example:

border-radius: 50px

Specifying Different Radiuses for a Corner

Border radius can be specified for some corners only. The order is:

border-radius:top_left top_right bottom_right bottom_left


border-radius:50px 0 0 0

border-radius:0 50px 0 0

border-radius:0 0 50px 0

border-radius:0 0 0 50px

Omitting border-radius Values

Any of the 4 values of border-radius values can be omitted.

border-radius:x is same as border-radius:x x x x


border-radius:30px

border-radius:x y is same as border-radius:x y x y


border-radius:50px 20px

border-radius:x y z, is the same as border-radius:x y z y


border-radius:50px 20px 10px

Border Radius with Elliptical Corner

For each border radius value, it can be a fraction, like this: border-radius:50px/10px 0 0 0. The 50px specifies the horizontal radius of a Ellipse, the 10px is the vertical radius.

css border-radius ellipse illustration
border-radius:55pt/25pt (image source)

Examples:


border-radius:50px/10px 0 0 0

border-radius:50px/10px

Border Radius Fullname Properties

border-radius is a shorthand for the following properties:

Browser Support

All major browsers support it since 2012.

CSS Effects

  1. CSS: Round Corners
  2. CSS: Box Shadow
  3. CSS: Text Shadow
  4. CSS: 2D Transform
  5. CSS: Image Rollover
  6. CSS: Background Image
  7. CSS: Transition
  8. CSS: Animation
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS Basics
  4. JS in Depth
  5. JS Reference
  6. DOM
  7. SVG
  8. JS Misc
  9. Web Dev Blog