CSS3 Border Radius Property (Rounded Corners)

Posted on Friday 10th Dec 2010 by James Bavington 2 Comments

This week our colleague Sam who usually records our web design video blogs is away on holiday. So we’ve decided to upgrade an older video blog on the new CSS3 border radius property. The CSS3 Border Radius property was announced as long ago as 2005, and has been one of the most commonly used and supported properties of CSS3. Introducing the Border Radius property onto your Style Sheets allows you to effectively ’round’ the corners of many HTML elements such as Divs and Input Fields.

The CSS3 Border Radius property is now supported on IE9, Firefox, Safari, Opera and Chrome. However as Mozilla’s Firefox has yet to fully adopt the standard Border Radius property, you also want to be doubling up by using the ‘-moz-’ prefix as per the code below:

Setting all 4 corners of an element

By setting a single radius as per the example below, you are effectively defining the border radius for all four corners consistently. This is the same principal as other common CSS properties like Margin and Padding.

border-radius:20px;
-moz-border-radius:20px;

Setting opposite corners of an element

If you define two radius’s like in the second figure below, then you are defining two opposite sets of corners. The first size sets the top left and bottom right, whilst the section radius controls the top right and the bottom left.

border-radius:50px 20px;
-moz-border-radius:50px 20px;

Setting all 4 corners individually

And finally, if you wish to set all four corners individually, simply add all radius’s like in the coding below. Again, this works much like Padding and Margin property definitions, however instead of ‘Top’ being first, you start with ‘Top Left’, going round clockwise.

border-radius:80px 40px 20px 10px;
-moz-border-radius:80px 40px 20px 10px;

About James Bavington

Away from computers, James enjoys mountains, military history and has an insatiable appetite for film - particularly 90's classics.

See all of posts.

Add on James Bavington Google+

James Bavington's Tweet's

This entry was posted in Web Design Videos and tagged . Bookmark the permalink.

2 Responses to CSS3 Border Radius Property (Rounded Corners)

  1. Eric Sawyer says:
    September 11, 2009 at 2:55 pm

    You guys must be the nicest people. I have wanted to do radius corners for some time but hated using images that bog the site. Thank you, thank you for that straight forward easy tute. love the accent. Eric

  2. Craig Riches says:
    December 17, 2010 at 7:15 pm

    Hi, this is a great tutorial! I’m going to go with what you suggested and start using subtle rounded corners on my new web pages.

    Now, I know this is completely unrelated, but how do you get the code on this page to be formatted as you have? I found that using tags are a bit long-winded. I was wondering if there was a quicker way of writing code/showing code on my actual web pages without going through the hassle of tags, etc. Any help would be greatly appreciated.

    Thanks very much again,
    Craig A. Riches

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>