• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Nile Flores Media

Helping You Rock Out Your Website Like A Rockstar

  • Home
  • About
  • Blog
  • Portfolio
  • Hire Me
  • Resources
  • Contact
  • Blogging
  • WordPress
  • Social Media
  • SEO
  • Web Design
  • News
  • Podcast
You are here: Home ยป Web Design ยป Tutorial: CSS Rounded Corners

Tutorial: CSS Rounded Corners

By Nile Flores 4 Comments


In the past, getting rounded corners meant you had to create a rounded rectangle, splice up the image, and then code it with HTML and CSS. A couple years ago, developers came up with a rounded corners attribute in CSS. It is called the border-radius.

This CSS trick does not currently work in Internet Explorer. These can best be seen in browsers like Mozilla Firefox and Safari. The corners will revert to being squared, but it will not cause any issues. Also, this trick is not considered W3 web standards compliant. It is a nifty trick that even Twitter has used on their layout.

The following below are the elements associated with this.

Firefox:
-moz-border-radius-topleft
-moz-border-radius-topright
-moz-border-radius-bottomleft
-moz-border-radius-bottomright

Safari:
-webkit-border-top-left-radius
-webkit-border-top-right-radius
-webkit-border-bottom-left-radius
-webkit-border-bottom-right-radius

You may want to use all so this effect can be seen in as many browsers as possible.

There are two different versions as some browsers read each code in a slightly different manner.

To get this effect, you merely specify the area, usually a division layer in your actual web page.

<div class="roundedbox"></div>

In your web page’s CSS style sheet, you will need to define what you want the roundedbox to look like. In the case of this tutorial, I want a background with white and a border of light gray. In the case of this tutorial:

.roundedbox{
background:#fff;
width:100px;
border:1px solid #c0c0c0
-moz-border-radius-topleft:5px;
-moz-border-radius-topright:5px;
-moz-border-radius-bottomleft:5px;
-moz-border-radius-bottomright:5px;
-webkit-border-top-left-radius:5px;
-webkit-border-top-right-radius:5px;
-webkit-border-bottom-left-radius:5px;
-webkit-border-bottom-right-radius:5px;
}

The 5px can be replaced by a smaller or larger number. This number tells the browser how much of a curve radius the corner will be. In the case of 5px, the curve is slight. With 10px, the curve is a bit more noticeable.

Try it out! You can also remove some parts of the code to make it different. For example if you wanted the top corners to only be rounded you just remove the CSS for the bottom border radius elements.

Have you tried this out?


Filed Under: Web Design Tagged With: css, tutorial, web design

About Nile Flores

Nile is a 43-year old female from the greater St. Louis (Southern Illinois side) area. Nile is a mother of 1 son. She is also a web designer and developer, a graphic designer, and a public speaker, who exclusively designs and develops using WordPress. She also blogs at GoDaddy's Blog, Verpex Hosting's blog and her very personal sites, Pixelled and Nail Polish Happy.




Related posts:

Basic HTML: Explaining the PRE tag Basic HTML: Using The Anchor Tag For A Page Jump Basic HTML Tutorial – What is HTML? Using An Image For The Submit Button

Reader Interactions

Comments

  1. Jenn says

    May 1, 2010 at 9:28 pm

    I can't tell you how many times I would have killed to be able to use this for the designing of the client sites I help one of my boss's with. But because she and the clients themselves use IE, guess who gets to create round-cornered squares and rectangles in Photoshop and then go through the fun of splicing and coding? *headdesk*

    Reply
    • Nile Flores says

      May 2, 2010 at 9:05 am

      I know the feeling. I can only hope that Microsoft gets their buts in gear and updates their browsers to allow this. I think only when this can be seen in most browsers will it become web standards compliant.

      Reply
  2. Amr Boghdady says

    December 31, 2010 at 1:21 am

    Thanks for great piece of code Nile!
    Too bad IE still ruins all the fun ๐Ÿ™
    I'm having roughly 25% of my website visitors use IE, so unfortunately I still have some fear of using it, else it would ruin my website appearance to the IE users
    My recent post Dative Case German

    Reply
  3. Veronica Cervera says

    December 28, 2011 at 4:52 am

    So true, who gets to create round-cornered squares and rectangles in Photoshop and then go through the fun of splicing and coding? Jenn has raised a good point here. I once had the experience of actually using curvy corners but it was not an easy experience ๐Ÿ™‚ Glad that today CSS are supported by all the major browsers.

    Reply

Leave a Reply Cancel reply

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

Primary Sidebar

Follow Me On:

  • Facebook
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube

Get The Latest WordPress & Blogging Tips

Sign up for my newsletter, and also get my free ebook on 10 Reasons Why Your Website Isn't Converting, and How to Fix it!




Try to be More Positive on Social Media

Note: You can click on image and view the video in a larger lightbox window.

Footer

The Blog

Lots of free information, tutorials, and more to help you bring your best foot forward with your website.

  • Blogging
  • WordPress
  • Social Media
  • SEO
  • Web Design

Get The Latest WordPress & Blogging Tips

Sign up for my newsletter, and also get my free ebook on 10 Reasons Why Your Website Isn't Converting, and How to Fix it!

Copyright © 2025 · · WordPress