Rounded corners and CSS — don’t bother just yet
16 May 2006
CSS3, when it becomes a recommendation, will offer web designers the ability to specify that elements should have rounded corners instead of square ones. This will be a great relief, because finally we will be able to stop messing around with background images and positioning.
Right now, you can specify rounded borders in your CSS, but it will only show up properly on Mozilla-based browsers. The property is called -moz-border-radius and it takes a number. So, to make a div with rounded corners, you might use something like this:
div {
border: 1px solid black;
-moz-border-radius: 20px; }
This isn’t too far off the official CSS3 working draft:
div {
border: 1px solid black;
border-radius: 20px; }
You’ll be able to specify two numbers there, which will let you make rounded borders that aren’t circular. You can read more about it on the CSS3 Backgrounds and Borders Module.
It will be great when this is released and browser support gets up to speed. At the moment, however, we should stick to fiddling with background images. Why? Because currently CSS rounded borders are ugly. I’ve made an image to compare rounded borders made in Photoshop with those drawn by Firefox with the -moz-border-radius property.
