A Web Design Community curated by Chris Coyier

Code Snippets Gallery

Code Snippets > CSS > Rounded Corners Submit one!

Rounded Corners

Standard:

-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */

Individual Corners:

-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 20px;
-moz-border-radius-bottomright: 30px;
-moz-border-radius-bottomleft: 0;

-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 20px;
-webkit-border-bottom-right-radius: 30px;
-webkit-border-bottom-left-radius: 0;

Shorthand:

-moz-border-radius: [top-left] [top-right] [bottom-right] [bottom-left]

-moz-border-radius: 10px 20px 30px 0;

Elliptical Rounding (Firefox 3.5+):

-moz-border-radius-topleft: [horizontal radius] [vertical radius];

-moz-border-radius-topleft: 10px 40px;

Elliptical Rounding Shorthand (Firefox 3.5+):

-moz-border-radius: [horizontal radius] / [vertical radius];

-moz-border-radius: 10px / 40px;
-moz-border-radius: 10px 20px 30px 40px / 15px 30px 45px 60px;

Above is the same as:

-moz-border-radius-topleft: 10px 15px;
-moz-border-radius-topright: 20px 30px;
-moz-border-radius-bottomright: 30px 45px;
-moz-border-radius-bottomleft: 40px 60px;

WebKit Elliptical Rounding

All corners:

-webkit-border-radius: 36px 12px;

Right corners only:

-webkit-border-top-right-radius: 50px 30px;
-webkit-border-bottom-right-radius: 50px 30px;

Reference URL

21 Responses

  1. Thank you for including my additions. Some more additions:

    Elliptical rounding:-webkit-border-top-left-radius: 10px 40px;
    Elliptical rounding shorthand:
    (notice: no slash)-webkit-border-radius: 10px 40px;

  2. Prem says:

    this is not compatible for IE browsers. Can u help me fix

    • Prem says:

      I did not still get answers to my question. This code is not compatible for IE browers

    • All versions to date of IE don’t support any CSS3 so you will either have to just employ progressive enhancement (i.e. decent browsers get rounded corners IE does not) or use images and or javascript to round your corners.

      @Prydie

  3. Opera doesn’t support border-radius yet either.
    You can make it work by including CurvyCorners:
    Then border-radius will also work in Opera and IE 4.0(!) and newer.

  4. aurel says:

    so what is more preferred this or the image style

    • John says:

      This (with or without CurvyCorners depending on the browsers you want to support).

      Creating images for round corners is more work, more http requests and more bandwidth then using border-radius.

  5. Robin says:

    I really hate the rounded corner issue in IE and other browsers with a lack of descent CSS support.

    Is there a nice and clean method that will work in all the browsers? Preferably a jQuery plugin?

  6. Theresa says:

    Only problem is that the CSS will not validate at the W3C CSS Validation Service.

    • Alex says:

      I think we’re beyond anybody really caring about validation as the CSS 2.1 spec has not even been properly supported. Ignore validation until then point where there is a definitive spec to actually validate against!

  7. george says:

    great and simple!

  8. Simon says:

    Is it true, that Firefox ignores rounded corners on images?

    Can’t seem to get it to work.

  9. marco says:

    Safari requires more than shorthand if you want differing corner radii. You have to write out each unique corner.

  10. Rolande says:

    To get rounded corners to work in IE 6-8 you need an htc file as a work around try this:

    http://code.google.com/p/curved-corner/

    Just download the file and follow the directions and you can integrate it with your current css solutions.

    It can be a little wonky so follow ALL the suggestions and dl the zip file with an example in it if you need to.

  11. Chris says:

    A great way to generate rounded corners is border-radius.com.

    It’s simple to use and generates the css for webkit and gecko proprietary extensions as well as the css3 version.

    You can also set the value of each corner and it’ll spit that code out as well.

  12. You can have a look as well at FlexiPanels CSS – a Dreamweaver extension that creates rounded corner CSS boxes without coding.

  13. Rafael says:

    Hey, Opera 10.5+ and Internet Explorer 9.0+ fully supports border-radius!

  14. Steve says:

    a noob question, with code like this just where in the css should a person put this type of code o make it work, in the body definition or elsewhere?

Leave a Comment

Remember:
  • Be nice.
  • Wrap multiline code in <pre> and <code> tags and escape it first (turn <'s into &lt;'s).
  • You may use regular HTML stuff like <a href="">, <em>, and <strong>
* This website may or may not contain any actual CSS or Tricks.