CSS Rounded Corners In All Browsers (With No Images)

CSS Rounded Corners In All Browsers (With No Images)

In the past two years, increased browser support has transformed CSS3 from a fringe activity for Safari geeks to a viable option for enterprise level websites.

While cross-browser support is often too weak for CSS3 to hold up a site’s main design, front-end developers commonly look to CSS3 solutions for progressive enhancement in their sites. For instance, a developer might add a drop-shadow in Firefox, Safari and Chrome using -moz-box-shadow and -webkit-box-shadow, and then be comfortable with this design enhancement falling off for IE users.

But wouldn’t it be great if IE users could see the better version of the page? Fortunately there are cross-browser hacks for the more common CSS3 attributes. These hacks not only allow CSS3 attributes to work in all browsers, but in turn allow designers and developers to use CSS3 in the central styling of their sites.

In this article we’ll walk through getting rounded corners working in all browsers. Firefox, Safari and Chrome are easy with the border-radius property, but we’ll have to jump through some extra hoops to get it working in IE and Opera.

After only a few compromises, we will have CSS rounded corners working in all browsers, and without using any images. Welcome to the ‘No Image UI Club’!

Update – With Opera 10.5, we no longer have to jump through any hoops at all! Details below

The easy part – Firefox, Safari & Chrome

It’s best to avoid hacks if at all possible, and luckily Firefox, Safari and Chrome all support rounded corners through native CSS methods. Let’s apply a border-radius of 20 pixels to everything with the class ’rounded-corners’:

.rounded-corners {
     -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -khtml-border-radius: 20px;
    border-radius: 20px;
}

The first thing you might notice is that we defined the border-radius four times over. This is because current browser implementations aren’t completely refined according to W3C’s recommendations. Since each of the browsers still has its own unique idiosyncrasies, they apply prefixes such as -moz and -webkit.

In our example, -moz-border-radius is for Firefox, -webkit-border-radius is for Chrome/Safari and -khtml-border-radius is for older Konquerer browsers. Finally, the plain, old border-radius is future-proofing for whenever browsers properly support this attribute.

Applying border-radius here will round all the corners of the element, but you can also round certain corners and not others, or even use elliptical as opposed to perfectly round corners. Read this CSS-Tricks article for more info.

Rounded Corners in IE

Kuato Lives with Bill Gates and Ballmer

None of the IEs support border-radius, not even IE8. When Microsoft released IE8, it’s almost as if they tried to catch up with browsers that were out when they released IE7. Don’t get me wrong, they fixed a lot and I wouldn’t trade even something small like display: table-cell for border-radius.

Fortunately, IE9 will have some CSS3 support, but until then we’ll have to use a border-radius hack in all IEs.

Although this hack is pretty fussy, I’ve gathered a couple guidelines that should help you debug any problems you may have.

First download this .htc solution: Curved Corner and upload it to your site. Then wherever you need a border radius, apply this CSS:

.rounded-corners {
    behavior: url(/css/border-radius.htc);
    border-radius: 20px;
}

The path to border-radius.htc works differently than you may expect—unlike background-image paths which are relative to the stylesheet, this path is relative to the page from which you call the CSS.

That’s why it’s a good idea to avoid relative paths like we did above.

Hoops you have to jump through for IE:

  • Any element with this hack needs to have position, so unless it already has a position, attach position: relative.
  • It can act funny on some elements that are natively inline, even if you attach display: block, although not all the time (fun!).
  • It also has issues with elements that don’t ‘have layout’. Attach zoom: 1; to get around this.
  • You can only use this on elements with the same border radius applied to all their corners.
  • When using this over anything translucent, a white ghost-line will stroke the rounded rectangle.
  • Don’t even think about combining this with another IE hack, such as a box-shadow filter hack.

Additionally, if you try to use this hack dynamically with CSS or Javascript effects, it will give you problems if the element either doesn’t exist or has display: none or visibility: hidden (basically if it isn’t rendered on the page). With JS, you can apply the behavior: url(/css/border-radius.htc) via Javascript after you append the element to the page. When using a CSS effect like :hover, you’ll have to find a more creative way of hiding the content, such as overflow: hidden or z-index: -1; hiding an element like this will still cause the browser to render it, even if it isn’t visible to the user.

Unfortunately there are still certain drawbacks to using this hack with dynamic content, for instance there’s a flicker when changing the background color of an element with Javascript, and I haven’t found a way to change it at all using CSS’s :hover.

Another IE option:

You might also think about trying this method, although it seems more complicated to me.

Update – IE9

A few weeks ago at MIX10, Microsoft announced IE9, and it seems like they may have finally gotten a few things right. Of particular interest is IE9′s support of CSS rounded corners, which actually surpasses the support of all other browsers. See here.

Making it work in Opera

Opera Web Browser

Opera has gotten its market share up over 2% so I’m officially supporting it, and I think you should too.

Update – Opera 10.5

Opera 10.5 has been officially released for Windows, and will be on the way shortly for Mac. I’ve always been a bit skeptical of Opera as a viable browser, but this new version really changed my mind. Besides being extremely peppy, Opera 10.5 supports a wide variety of CSS3 properties, including CSS rounded corners, via border-radius (that’s right, no prefix).

If Opera doesn’t need a prefix (e.g. -opera-border-radius or -o-border-radius), then that should mean that they are supporting border radius according to w3c’s specifications. However I haven’t been able to find anything to confirm this.

Workaround for Opera 10.10 and below

Additionally, there’s a decent workaround for Opera 10.10 and below. Since version 9, Opera has supported SVG generated images, which are actually super cool. This allows you to draw images using CSS and an encoded SVG string. Don’t worry, you don’t actually have to write it; here’s a really handy round corner generator for Opera. This generator will allow you to build the CSS SVG output you need to support border-radius.

The Opera method is a little more robust than the IE hack, in that it supports rounding only certain corners of an element, and can also be easily used dynamically with CSS and Javascript effects.

The downsides are that it can only be used with block colors for whatever has the rounded corners, and whatever it is sitting on. This means that you can’t use it over anything textured or semi-transparent. Additionally, this method causes a brief flicker while it loads up, which is mostly noticeable when using it dynamically.

Finally, the Opera method is a little annoying to use, since you have to generate new CSS output for every color combination.

In Summary

These methods allow developers to support CSS rounded corners in all major browsers. As of IE9, IE will support border-radius, but until then this hack allows us to support it with only a few conditions (and for all the losers still on IE6). Opera has already implemented border-radius support since this article was written, but for versions prior to 10.5, the Opera SVG hack works well enough. (You may consider ignoring legacy support for Opera, due to its low market share.)

Although I wouldn’t necessarily recommend these hacks for a client’s site, they are pretty fun to play around with, and I ended up using them all over jonraasch.com. Combining this with some box-shadow and this CSS triangle trick, I was able to make it so that the only image assets my site loads are its background, logo and various content images. And I think that’s pretty cool :) .



Jon Raasch

Jon Raasch is a UX nerd and free-lance web designer / developer who loves jQuery, Javascript & CSS.




You Might Also Like:


180 Comments to “CSS Rounded Corners In All Browsers (With No Images)” RSS 2.0

  1. Omar says:

    Wow your a life saver! thanks so much!

  2. Daniel15 says:

    Nice article :)

    Isn’t Opera 10.5 the current beta, and 10.10 the current release?

  3. Wow, excellent tutorial… I’m off to practice!

  4. nazrien says:

    wow!! this is super great!!!! thanks

  5. Yeap, this one is a killer. Css3 will be a fun little toy for me, lots of creative inputs, but The browsers need to pick up the css3 much faster!

  6. Brilliant, hope this works better than curvycorners, just insane why browsers don’t make this uniform as it’s such a useful feature.

  7. Opera 10.5 is a future update I believe. Like when Firefox jumped from 3.0 to 3.5. Opera 10.10 is an upgrade from the current Opera 10. I know it’s shitty numbering, but hey … it’s Opera :p

  8. seeal says:

    great thx 4 sharing :D

  9. snlr says:

    Nice article, thanks!

    The Opera solution seems to have even more limits than the one for IE. I don’t think a site wouldn’t be “supporting Opera” if it showed normal corners to the visitor. How important can rounded corners be for the site?

  10. ben says:

    Nice tutorial, but strictly speaking this isn’t CSS rounded corners in all browsers, as the .htc relies on javascript, so if you have it turned off you won’t see them…

  11. Leave ie6 alone. Let him die in peace.

  12. Erik says:

    What about Curvy Corners? It also has some small bugs but it will autmatically figure out of there is used any -moz-border-radius and round the corners.

  13. Jordan says:

    Wow, I hadn’t even realized Opera stopped support for it with their latest update. I had also been under the impression that they had adopted border-radius versus using a prefix? According to their dev blog they had always used border-radius sans prefix (http://dev.opera.com/articles/view/css3-border-background-boxshadow/). You might have to view through Google’s cache because it seems to be down right now.

    Anyway I just did a little digging around to check and it shows that it still supports border-radius for 10.10. http://www.opera.com/docs/specs/presto22/css/properties/.

    Where did you read that Opera dropped support for it?

  14. Jordan says:

    Sorry for the double comment; Decided to upgrade to 10.10 and low and behold. That’s a big move to have dropped that support. :(

    Poor Opera users will have to deal with pointy corners; I hate using alternatives just for other browsers. I let it downgrade instead.

  15. Aery says:

    BRAVO JOHN, BRAVO.

    In my blog Gtricks I have to hatefully switch from rounded corners to rectangular boxes since it wasnt supported well everywhere and hence it wasn’t giving a same uniform feeling to users on all browsers.

    IE8 has done henious crime for not implementing rounded corners.

  16. Really great article. overcomes some IE pitfalls

  17. Jon Raasch says:

    @daniel15 + @Niels Matthijs – Yeah I was just baffled as to why they would remove the support, but what you’re saying makes more sense, that 10.5 is the beta and 10.10 the current release (really confusing versioning tho…)

    @snlr – The nice thing about the Opera hack is that it supports rounding some corners and not others, which is something I use often, and it additionally works better dynamically. But yeah it’s way more annoying to use.

    @ben – Good point on .htc using Javascript, but I stand by my catchy title :)

    @jordan – My mistake, 10.5 is a ‘pre-release alpha’ and 10.10 is the current release. Kooky version numbers… Out of curiosity, have you gotten any of those properties to work with Opera sans-prefix?

    @Romi – Amen brother!

  18. c. says:

    “10.5 is the beta and 10.10 the current release (really confusing versioning tho…)”

    How is this confusing? 10.5 (10.50) is greater than 10.10.

  19. Jon Raasch says:

    @c. – IMO version numbers shouldn’t be treated like decimals. 10.5 should be followed by 10.6, 10.7, and then 10.10, 10.11, etc. Otherwise you’re forced to jump to version 11 after 10.9, even if it doesn’t make sense.

    This version should be numbered 10.1.0 if that’s what they’re going for.

    And if they should be treated like decimals, wouldn’t you reduce 10.10 to 10.1?

  20. Rob Miracle says:

    Microsoft and Opera can build better browsers and more importantly their users can get better browsers. No hacks. They can have a square look.

  21. Peter says:

    I’m having some issue with this hack. I have a background image (w/ placement) but when I use this hack it automatically repeats the whole image.

    How can I get around it?

  22. IE9 supports border-radius in the same fashion as Opera 10.5

    http://blogs.msdn.com/ie/archive/2009/11/18/an-early-look-at-ie9-for-developers.aspx

  23. calambre says:

    Half of the comments mentions Opera, that wouldn’t happen even an year ago… it’s a good thing. Opera 10.5 will be out by march, with a new render engine that supports rounded corners. The alpha is very usable and by far the best version of this browser.

  24. Jordan says:

    Thanks for clarifying on the versions there! I’ll have to revert back to the alpha release to double check. Truthfully, I never actually *looked* to see the support. Rather I added the support sans prefix due to numerous articles announcing Opera actually using prefexless border-radius and having seen it’s support on their site.

    I’ll let you know :)

  25. syafiqzaimi says:

    thanks for the info… it helps me a lot

  26. christoff says:

    Too bad it doesnt work in ie6, the most saturate browser in the market.

  27. Jon Raasch says:

    @christoff – The .htc hack described above works just fine in IE6, I’ve actually had more trouble with it in IE8 than in IE6 if you can believe that. Also IE6 is by no means the most widely used browser on the market. See these stats

  28. Carlos says:

    Just seems like too much work to add 5-6 CSS methods to get rounded corners. I may just stick with the image corners. Good post though. Good things to know. Ugh IE

  29. aledesign.it says:

    Nice post and really useful! Thanks for the sharing!

  30. Echoweb says:

    I don’t understood because there are people that use today IE… when there are other browser that are better

  31. JoshuaW says:

    Looking at your site in IE8, the Home, Portfolio, About, etc tabs have rounded tops, and square bottoms. If the border-radius.htc doesn’t support specifying the radius for each corner, how do you accomplish this on your site for IE8?

  32. Jon Raasch says:

    @Carlos – Yeah it’s a pain to implement, but in terms of filesize and load time you’re better off with the hacks. Provided you can deal with all the compromises they entail.

    @Echoweb – I know it sucks that people use IE6 but think of it as a challenge :) .

    @JoshuaW – Hehe good question. To get the bottom corners square in IE, I used overflow:hidden on a wrapper div, then absolutely positioned the tab so that the rounded border rendered outside of the wrapper.

  33. tinos says:

    that picture of Bill Gates… HAHAHAHHA
    Thanks for the tutorial, and thanks for the laugh, it was so appropriate.

    Pretty much I’ve decided, screw IE, people won’t get the full experience if they insist on using it. /not using the hack.

  34. Jon Raasch says:

    @tinos Hah yeah I was really proud of that pic of Gates & Ballmer, but it totally flopped on 4chan a few months back. Glad you like it :) .

  35. Buck says:

    Hi,
    Great site loads of information for a newbee. Your round corners tut is great but I a using DNN 5 and have tried to implement on this page http://www.kidfit.com.au/test.aspx. Works well for firefox but not IE. Have I done this right
    code:

    .block {
    height: 550px;
    margin-right: 10px;
    padding: 20px;
    background: #ccc;
    -moz-border-radius: 15px;
    -khtml-border-radius: 15px;
    -webkit-border-radius: 15px;
    #behavior: url('border-radius.htc');/* override for Microsoft Internet Explorer browsers*/
    #border-radius: 15px;/* override for Microsoft Internet Explorer browsers*/
    }

    Any help would be appreciated.

    Kind regards,
    Buck

  36. cool solution there mate!!, it has been some time I’m looking around something like this one, thanks for sharing…

  37. Marco says:

    How does one do individual corners with this solution in IE6+? Say I just wanted to do the top corners in order to create a “tab” feel to the element, border-top-right-radius, border-top-left-radius didn’t work…

    Thanks!

  38. Sandra says:

    Thanks for this tutorial. Everythings works fine, even in IE. Except for one thing: when I resize font in IE the layout breaks. A refresh makes it all alright again but ofcourse that’s not what I’m looking for.

    I’ve tried to give the div with the class position:relative; but to no avail. Also zoom:1; doesn’t make it right.

    Any ideas?

    Thanks,

    Sandra

  39. evanism says:

    Just use a bloody image. Workin every broswer and device and involves no dicking around. After 15 years of web design I am sick to death of hacks and alphas and workarounds. Just do what is simple and move on.

  40. Melissa says:

    Thanks for such straightforward info. My question now tho is, how do you make rounded corners EASILY on form fields? I see some examples online, but most involve Javascript. Any tips on doing that in all CSS?

  41. Great stuff, thanks – images are no good for flexible width layouts with patterned background, so this is extremely helpful. Works perfectly.

  42. jim says:

    Same question as Marco above…what’s the best solution for IE to get rounded corners only on certain corners?

  43. Chriss says:

    A nice clean, well explained and clearly detailed answer to the gnawing CSS rounded corners issue. Thanks!

  44. roniwahyu says:

    how about using css2?

  45. Joe says:

    Wow.this is awsome.
    but i do have this problem.I tried it on a joomla project & it seems not to work on IE.I have done the styling on the template’s css & uploaded the .htc doc on the css directory.The code is exactly the same as yours exept for the colors.What is it that am doing wrong pliz!

  46. Rolande says:

    Thanks Jon I’ve been banging at this for awhile and your article brought all the elements together to solve this problem easily.

    To answer Joe and a few others who are having IE issues – the .htc solution is wonky at best I had to work at it for a bit to get it to display rounded corners consistently.

    As to controlling individual rounded corners of different sizes as Jon said the .htc isn’t going to help you there as all corners have to be the same.

    Take a look at Jons “hoops you have to jump through” for IE section of this article, everything he posted there should get you to 4 rounded corners.

  47. John Patrick says:

    Thanks for the clear summary Jon – it worked a treat for me.

  48. Joe says:

    Thanx Rolande.I got it working now in both IE, Firefox, Safari & even some other browsere.Thnx alot Jon & all of you for this.I’ll have to show this to my friends cz most of them still don’t knw this technique, they still use images for the rounded corners.Thnx once again!

  49. Alex says:

    Thanks for this, Jon!

    Had some fun rounding things off on my little site – helped in great part by this very useful post.

    Best,

    Alex

  50. ilithya says:

    Thank you so much for this detailed article on the topic.
    I was reading so many others on the web, but none of them could help me to achieve the round corners in IE, as it was the first time I try did, and they didn’t explain as deep as you do in your article.

    Now I successfully have rounded corners on IE in my site.

    Happy coding!

  51. smkannan says:

    it is wonderful tutorial

  52. I’m calling the .htc file with an absolute path in an IE hack sheet but it knocks out the div background colours. I think it’s down to inline inheritance, but display block, position relative and zoom don’t make a difference.

  53. Alex Reality says:

    Same thing here. When I call .htc file with an absolute path, my background disappears in IE. I wonder if this is somehow connected with transparency I’m using in my background image… But when path to .htc file is relative nothing happens at all – just square corners in IE.

  54. solexy says:

    thx, great article

  55. jcc says:

    is there an online demo for testing?

  56. vijay says:

    I really liked this one. and in future i really like to visit this site again for thsese kind of tips

  57. JDS says:

    Jeebus H Crisco hasnt the browser world resolved this yet? I leave web development for a couple of years, expecting ridiculous issues like this to clear themselves up, and all I get for my wait is a whole lotta nuthin. At least IE6 is dead, right? RIGHT?

    I like your website, but by far my favorite thing is your “pantsless” easter egg.

    Thanks for the help. Seeya.

    PS: Why cant I put single quotes in this comment space???

  58. channa says:

    Thank you so much Jon. Keep it up the good work.

  59. serge says:

    Hello
    IE8 doesnt like this hack !
    The solution is using this attribute to Parents element : position: relative; z-index 0;
    Thanks for your blog…
    Serge

  60. Dingus says:

    Very nice CSS trick! I will be using this in a lot more projects. I did run in to a weird IE bug though. I use a js function to fade border/font/bgcolor style of some newly rounded buttons and it becomes a ‘not round’ div again. Does anyone have a javascript or css fix for this issue?

  61. Julie says:

    This saved me SO much time! Thank you!!

  62. Andy Piddock says:

    This is great but I had a lot of trouble with IE8 often not rounding the corners even though the htc file was being loaded.

    The Solution (this has now been confirmed on 3 sites amending existing css).

    Add a dummy empty rounded corner div just after the Body tag:

    /* Rounded corners – All browsers */
    .rounded-corners {
    background-color: #ECE9D8; – match to your background
    width: 900px; – match to your width
    height: 0px;
    -moz-border-radius: 1px;
    -webkit-border-radius: 1px;
    border-radius: 1px;
    behavior: url(css/border-radius.htc);
    }

    It seems that if the htc file is applied to an empty (clean) div, IE is then much more happy with applying the htc to subsequent divs and elements.

  63. ipad apps says:

    Thanks for this tutorial, however do you know how to do a table with strokes (rounded corner strokes) w/o using image? I prefer CSS, if someone know, please do reply, kindly thanks.

    Rick

  64. RT says:

    If am using drupal, how will the path to the htc file be used?
    I copied it to my site in a folder with path similar to:

    /www/sites/mysite.com/themes/garland/

    where the htc file is stored in the garland folder.

    what path do i need to use in the css: behavior(path to htc) as u mentioned :
    “this path is relative to the page from which you call the CSS”, but drupal store its pages in a db instead of in folders…?

  65. tony says:

    kool stuff Jon!

  66. Carly says:

    THIS ISSSSSSSSSSSS the best way I have found!
    Way to go!
    Thank you!
    (How can I add a shadow to the right border???)

  67. Steve says:

    Really nice stuff. It was just what I was looking for. I have one question. On one of my pages I have the rounded corners on the two side bars and the main content. Inside the main content I want to put a form. Any idea how I can turn the rule off for just the form?
    Thanks,
    Great work.

  68. Loc says:

    This is great discussions. I’m currently having problem with background-xxx (background-repeat, background-position, and etc…) properties when use in conjunction with border-radius.htc. The background image kept on repeating itself when I specified background-repeat:no-repeat.

    I think Peter already asked this question but no reply yet.

  69. Jethro says:

    Just what I needed, landed on the page to be greeted by the icons of the 5 browsers I use.

    Websites like this keep me inspired to getting my freelance web development career off the ground :)

  70. Pink says:

    Works perfectly in IE7 but why can’t I get it working in IE8 if everyone else does?? Followed instructions exactly as far as I can see.

  71. blestab says:

    Awesome stuff, these site http://www.cssportal.com/css3-rounded-corner/ goes further and generates the css for you – for the lazy ones :)

  72. louis says:

    This is great discussions. I’m currently having problem with background-xxx (background-repeat, background-position, and etc…) properties when use in conjunction with border-radius.htc. The background image kept on repeating itself when I specified background-repeat:no-repeat.
    Visit
    http://www.filesharepoint.com/
    OR
    Fileshare

  73. Jeff says:

    First off, great article. CurvyCorners seems to have broken sometime in the past few months (its own site degrades to square on my Windows test VM) and I weeded through so much outdated and just plain bad information looking for another solution.

    I just wanted to point out another quirk I discovered for anyone else trying to make curvy elements without a border. border-radius.htc seems to give my curvy divs, which are supposed to have a border-width of 0px, a border-width of 1px, with border-color defaulting to whatever the color attribute is set to. I tried explicitly setting the border-width after I called border-radius.htc and this was not respected. So I explicitly set border-color to the same thing as background-color instead, and will live with divs being 1px larger in IE.

  74. jeiboy says:

    How about for the new browsers released?

  75. Thoor says:

    THX a lot for the advice with the path to the border-radius.htc – I tried to use this this several times, but no one told me before, that the path is different to other CSS URLs lik images …

    Greets from germany

  76. Frank says:

    Nice tutorial on round corners. I’m going to try that out! thanks

  77. Eddie says:

    Thx man

  78. Bold says:

    Thanks man – this saved my bacon!

  79. jehzlau says:

    perfect! just what i needed! I hope this works in my list navigation. :D

  80. jehzlau says:

    Yay! just tried it and it works great! I didn’t try the IE hack though. Anyway, I don’t care if it works with IE or not. yay! Thanks Jon Raasch! :)

  81. Web says:

    Whew.. Thanks mate.!! great post. One question tho, why do people still use IE.. Arrrg..

  82. Pranzyt says:

    @Web

    People still use IE simply because it is better than the best. :)

  83. Ullas says:

    Thanks for this solution.. this saved lot of time for us…

  84. mdsouza says:

    Thanks Jon Raasch for sharing this , and a shout out thanks to Andy Piddock for the IE fix. Have a great new year everyone.

  85. Marvl says:

    There is the world, and then there is Microsoft (25 square miles surrounded by reality). I suspect CSS3 will be fully supported in IE9, CSS3 support will be removed in IE10, and will be partially reinstated in IE11. That’s the way those thumb-sucking idiots like to do things. Ineptly. Incompetently. Arrogantly. Stupidly-while-they-slip-on-their-own-drool-and-fall-off-their-100-million-dollar-yachtly.

    The problem is, of course, that we continue to jump through hoops to support the IE family of brain-dead children. If everyone could be persuaded to drop support for IE for just 1 year, that might be enough to drive a stake through its heart.

    Now, is there a similar sharp stake we could use on that other class of clueless idiots, liberal politicians? But, I digress…

  86. Alan says:

    Thankyou!! I just let out an audible ‘Wahay!’ :]

  87. Hugo says:

    Because the people use windows….

  88. Jackie says:

    @Andy Piddock – Thank you thank you! I tried everything else, that is the only fix that worked for me!

    Jon, please add that info to the article, it’s very helpful!

    Andy Piddock said:
    This is great but I had a lot of trouble with IE8 often not rounding the corners even though the htc file was being loaded.

    The Solution (this has now been confirmed on 3 sites amending existing css).

    Add a dummy empty rounded corner div just after the Body tag:
    /* Rounded corners – All browsers */
    .rounded-corners {
    background-color: #ECE9D8; – match to your background
    width: 900px; – match to your width
    height: 0px;
    -moz-border-radius: 1px;
    -webkit-border-radius: 1px;
    border-radius: 1px;
    behavior: url(css/border-radius.htc);
    }

    It seems that if the htc file is applied to an empty (clean) div, IE is then much more happy with applying the htc to subsequent divs and elements.

  89. Kim says:

    This looks very cool. But will it work with a list in IE?
    I’d like to have a page with a rounded corner box and inside the rounded corner box would be rounded corner buttons. I can get the rounded corner box and the rounded corner buttons inside the box in Safari or Firefox, but IE only shows the rounded corner box and not the rounded buttons.

  90. Dhatchana says:

    Thanks a lot… you save my time.

  91. Art says:

    Seems this hack doesn’t work if the intended element to have a rounded corner is embedded inside another element that has a background color and/or image…

    Oh well…

  92. Liz says:

    I’m having the same issue as Art. If the div with rounded corners is sitting in another div, it doesn’t work. I’ve tried all the other solutions, adding the other lines of code, etc. Oh well. Please die, all old IE versions, and bring on IE9.

  93. Chris says:

    Have to say thanks for this info because it worked a treat on my template, with very few problems. Rounded corners really can refresh an ageing design.

  94. Tushar says:

    Jon Raasch ,I have a small request for you.

    I loved your script.I implemented it on my joomla component.

    It’s coming rounded for all browser but not in IE.

    I am stuck whether the htc path is wrong or its getting overidden by joomla css files.

  95. Daniel Likin says:

    Wow, thanks dude for the CSS tutorial above, it worked.

  96. Rosa says:

    I have a page and the Round Corners are not working in IE (I have IE8). The website is http://mochicaweb.com/arash/about_us.html. I first thought that it might not be working because of the Cufon Javascript. But that is not the reason.

    Please feel free to take a look. Any help is very much appreciated thanks.

  97. iSun says:

    First,thanks a lot.This article helps me a lot.But I found a problem as it mentioned above:the div is embedded inside another div,when I set the background color of the parent div,the child div which have round corner will disappear!

    And how can I deal with this problem?

  98. Vincent says:

    GREAT Tutorial!!!! For the longest time, i had to cut corner images. Now…..no more images thanks to you!!

  99. Jeff says:

    what do i use as the html code?

  100. Micox says:

    Hi.
    I find a problem with transparent backgroundColors and v:fill in IE8 (i dont have tested in anothers IEs yet).
    The background color is turnet do black if original is ‘transparent’.

    I think that solved this : fill.color = (fillColor==’transparent’) ? ‘none’:fillColor; (line 93).

    Thanks your code. Its awsome.

  101. Very nice CSS trick! I will be using this in a lot more projects. I did run in to a weird IE bug though. I use a js function to fade border/font/bgcolor style of some newly rounded buttons and it becomes a ‘not round’ div again. Does anyone have a javascript or css fix for this issue?

  102. mred says:

    I prefer only the pure CSS version, IE users don’t deserve beautiful rounded corners.
    http://it-things.com/index.php/2011/03/pure-css-rounded-corners-no-images/

  103. Alok says:

    WOW you are great. Thank you so much.

  104. Richard Yoiun says:

    FANTASTIC. You are so amazing. Thank you so much. I’ve spent over 10 hours trying to sort this out. I can’t epxress my thanks in words.

  105. Dana says:

    Same problem as Art above — using the behavior for IE causes the borders and background completely disappear the if containing element has a background color or image; so seems completely useless…

    Example: See the example html file from the link you have above to download the htc file; just change the containing div to have a background color. All the boxes disappear.

  106. Jz says:

    You are lifesaver m8 thx so much!

  107. Nate says:

    Thanks man! This is really what i needed! Oh, I also like the design of your website.

  108. Hincor says:

    This is a freaking unbelievable tutorial!!!

    What Can I say!!!

    AMAZING
    EXCELLENT
    BRILLIANT
    ROCK!!!!!!!!!!!!!!

  109. Jules says:

    I love it, but the only issue I am having with this is when you resize the browser window in Internet Explorer, the div stays static. :/

  110. Mike Bethany says:

    Great help, thanks!

    Wouldn’t it be great if we could just stop supporting IE? It’s like the whole class has to slow down for the one kid that refuses to do his homework.

  111. Dave says:

    This is great. Thanks so much!

  112. vivek says:

    but what about when we need a white background :(

  113. vivek says:

    sorry yes its working, not an issue if applies background color border displaying :)

  114. Wilson Hui says:

    Good to know that IE 8 and below doesn’t support this rounded corner thing, saved me a bunch of time testing! Unfortunately, that means I’ll have to stick with non-rounded corners for some time. boo!!!

  115. Sara says:

    Hey.. nice tutorial.. but this border-radius.htc still not working for my IE 8.. I ran a demo http://code.google.com/p/curved-corner/ , that worked in my explorer , i could see round corners but when i run my own website in IE with .htc in it.. it doesnt work.. please help.. i really need that.. i dont want typical rectangles

  116. I messed around with the .htc file for like 3 hours…needed a static link not a relative link. That’s what I was missing. Thanks man! Now got rounded corner in IE.

  117. Rimsa says:

    The code for rounded corner is not supported in IE…….

  118. gabriella says:

    hey, thanks a lot! just added to my pages… i will run the test now, but you saved a lot of time already for me!!

  119. Shawn says:

    Trying to get the border-radius.htc to load for IE8. Will not work with nestled DIV tags. Works fine in all other browsers. The code for classname is what everyone here has been trying to work…

    .classname{
    margin: auto;
    border:solid 2px #33FFFF;
    background:#EEEEEE;
    text-align:center;
    padding:5px 5px 5px 5px;
    -moz-border-radius: 25px;
    -webkit-border-radius: 25px;
    behavior: url(/border-radius.htc);
    border-radius: 25px;
    height: auto;
    width: 50%;
    }

    If anyone can find a way to make IE behave with more than one DIV tage, please share. This is driving me nutts.

  120. Rob Lynch says:

    I’m glad you updated the post (towards the bottom) that IE finally got it right.
    I find having 4 different version of getting Rounded Corners via
    things like
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -khtml-border-radius: 20px;

    To be a HACK. it may be supported, but it isn’t the definition of the CSS 3 specification. At least IE supports the native CSS format of border-radius. Too bad we had to wait for IE 9, but when you swap to HTML5 and the new Canvas Object, IE10 ROCKS.. better support and speed than anything else out there. (IE9 is still missing is a few areas. but they (MS) is making great steps into coming inline with the true standards as defined by wc3.

  121. Niko Lappalainen says:

    I have tried everything to display my blog round corners and shodow boxes when using IE 9, even so called “hacks”. In my opion, M$ should shame themselves not supporting standart css code!

  122. THX a lot for the advice with the path to the border-radius.htc – I tried to use this this several times, but no one told me before, that the path is different to other CSS URLs lik images …
    Greets from germany

  123. Mark says:

    Thanks loads Jon nice fix works really well. Spent a lot of time yesterday trying to get IE to display just rounded top corners for a tab menu I am working on. Got it working in every other browser no problem but usual story no joy with IE. Does anyone know of a way to round just top corners of a div in IE?

  124. Mark says:

    Without resorting to images and JS. Cheers

  125. Thanks so much, I have been using images for my rounder corners all along. Now this saves my day.

    @Sara: “I ran a demo http://code.google.com/p/curved-corner/ , that worked in my explorer , i could see round corners but when i run my own website in IE with .htc in it.. it doesnt work”

    your solution :- put this line of code “border-radius: 7px;” about the “.htc”

    e.g.

    border-radius: 7px;
    behavior: url(border-radius.htc);

  126. Chris Quinn says:

    Exactly what I was looking for…now I need to figure out how to just round the “top” corners…is this possible?

  127. Liyu says:

    Great, IE does suck….

  128. Liyu says:

    the .htc for IE is tricky, the css should include the relative path from the page
    to the .htc file??

  129. iSafa says:

    Thanks for the great tutorial it saved my life!

    I noteced it will not work if u r using the following css code, this one is for making gradient background color

    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=’#fdf1eb’, EndColorStr=’#eceada’);

    when i removed it it start working

    Thanks again :)

  130. Stephen says:

    Solution: Chrome Frame for IE

    Because IE seems like it will always be behind the times.

    http://code.google.com/chrome/chromeframe/

  131. Fitz says:

    I am trying to get this to work in a hover state, but it is not working no matter which way I try it. Is this possible with your script? Any advice would be great. Thank you.

  132. Bang says:

    Hi Jon,

    I modified border-radius.htc to support changing background color of the buttons. The buttons’ class name must contain a string “ieHoverSupport” and your css file will use “.iehtcover” to define hover background color. This code is placed below the first public:attach tag.

    <public:attach event="onmouseover" onevent="oncontentover(‘iehtcover’);"/><public:attach event="onmouseout" onevent="oncontentout();"/>

    And inside script tag, add these two methods:
    function oncontentover(classID) {
    // only execute when element class contains ‘ieHoverSupport’
    if (this.className.indexOf(‘ieHoverSupport’) != -1) {
    this.element.orinalColor = new String(this.element.vml.firstChild.color);
    this.element.orinalClass = new String(this.className);
    this.element.removeAttribute(“style”);
    this.className = this.className + ‘ ‘ + classID;
    this.element.vml.firstChild.color = this.currentStyle.backgroundColor;
    this.style.background = ‘transparent’;
    }
    }
    function oncontentout() {
    // only execute when element class contains ‘ieHoverSupport’
    if (this.className.indexOf(‘ieHoverSupport’) != -1 && this.element.orinalClass != this.className) {
    this.className = this.element.orinalClass;
    this.element.vml.firstChild.color = this.element.orinalColor;
    }
    }

  133. Dominic says:

    Thank You Jon! You always help me out with your blog, ever since you talked me out of using tables the sky has opened up.

    One thing I noticed, I could not get this to work in IE despite all the troubleshooting suggestion. This was solved when I used this htc file instead.

    http://fetchak.com/ie-css3/ie-css3.htc

    Thank you for all your Insight Jon and I will stay tuned in.

    -Dominic G.

  134. PhotoshopWarrior says:

    This article helps me adjust the TOP rounded corners, tnx buddy

  135. Sarah says:

    Aaag! Tried this a few times, but the background colour flickers then stays off? Any idea guys? Views fine in ff as usual lol Here’s the link:

    http://www.nationaldebtrelief.co.uk/debt-relief-blog/category/debt-advice/

    Here’s the css:
    padding: 10px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    -khtml-border-radius: 5px;
    border-radius: 5px;
    behavior: url(http://www.nationaldebtrelief.co.uk/border-radius.htc);
    border-radius: 5px;
    position: relative;

    I have also tried adding block display and attaching zoom, but to no avail.

  136. Shaun says:

    Excellent, Thanks!

  137. Pancho says:

    It had removed the background color on the header when i used this:

    -moz-border-radius:0px 0px 12px 12px;
    -webkit-border-radius:0px 0px 25px 25px;
    behavior: url(border-radius.htc); (USING THE border-radius.htc file is not working)
    border-radius: 20px;

    But when I used the other file; (ie-css3.htc) IT WORKED PERFECTLY!!


    -moz-border-radius:0px 0px 12px 12px;
    -webkit-border-radius:0px 0px 25px 25px;
    behavior: url(ie-css3.htc); (IT WORKED! Rounded corners with the COLORS on it)
    border-radius: 20px;

    Thank you very much for this article. Now I can continue with my project!

  138. Cesar says:

    Great plugin, but I’ve a question:

    Does it work only to apply rounded corners to ALL borders? I’m trying to apply it only to the left bottom border (-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; border-bottom-left-radius: 5px; ) and it’s not working.

    Wether the radius are applied to all corners or none of them. Is there a way to reach this result I’ve described?

  139. Ahmed says:

    Nice, ive been looking for this…thanks so much

  140. Dave says:

    God, Damn, INTERNET EXPLORER!

    Thanks for the alternatives, very appreciated

  141. Alec says:

    Hi

    I’m trying to use your hack, but i’m having a problem when its inside a div that has a background-image. Please let me know what i need to do.

    thanks Alec

  142. Bongani Given Ndlovu Ngomani says:

    The CSS is easy!! Just that the browsers are not keep upping with the programs! Even with transparency, some of the browsers are not supporting it!

    And some of the clients use old browsers and_ we should offer a link to download new browsers to our clients!

  143. alex bouca says:

    Hey
    I am very new to the web design thing. I have started learning CSS and have built a site for a client http://www.acumencapital.co.za. I have used the rounded corners in all browsers but my client still uses IE 8 and doesnt like IE 9 and is demanding the rounded corners on the site in IE 8.

    I have copied your IE 9 code into the style sheet into the style identity for the corners to be rounded but it doesnt seem to work. could you help with why?
    thanks a lot alex

  144. Mohamed kalith says:

    border radius htc not working in ie8 .. joomla1.5 puritty ii templates
    I had using htc file…
    but no use in ie8
    anybody knows the solution …plz post here
    .rounded-corners img{
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -khtml-border-radius: 20px;
    border-radius: 20px;
    }
    .rounded-corners img {
    behavior: url(/css/border-radius.htc);
    border-radius: 20px;
    }

  145. Chan says:

    can you please tell me “-moz-outline-radius” CSS3 code for Internet Explorer and Other Browsers. now works only with FireFox.

    am trying to create a round cornered outline for a round cornered DIV.

  146. jamescool says:

    Great! NIce dude..

  147. Andrei says:

    This is not working for me. It doesn’t work all the time. I have other styles on the div I’m trying to make rounded corners on and when I apply this, it removes the background image.

  148. Anton says:

    background-repeat: repeat-y;

    Will not work together with:

    border-radius: 4px;

    ###> SOLUTION:
    http://css3pie.com/

    Work both with repeat, background-image, border-radius (rounded corners) etc.
    GREAT fix/hack that really does the job 100% flawless!

  149. RJ says:

    doesnt work in ie8 :( and in ie7 it messes up its z-index and its background color, guess ill have to keep searching for a real solution

  150. Andrew Kear says:

    How do make rounded left and right corners on a tab in CSS.

  151. ifeanyi says:

    Nice post. IE still gets me angry. However I still wonder why folks dont want to move beyond IE6? Its like refusing to leave the stone age in a dynamic world. Update your browsers guys…

  152. nev says:

    This hack does *not* work in IE6, taking all the above into consideration.

  153. swagatika says:

    thanks for the example……………….

  154. Timby says:

    Thanks a lot for this mate, exactly what I was after and works straight out of the box. Now my design looks slightly less bad ;) Cheers!

  155. Vishy Moghan says:

    Hi all
    I know I am a late comer to this thread, just wanted to point out that Opera 11.x seems to support round corners natively, at least on the Mac. I am wondering though as a designer who really would rather not have to actually make sites, but has to anyway, is there a way of incorporating IE versions into the general CSS style sheet instead of having to include one CSS for IE 6 and one for IE 7 just to make your designs look the way you want them to?

    It’s so frustrating that MS insists on having a different protocol to all other browsers. I frankly don’t see the point of it. For me it is especially hard since as a Mac user, it means every time I design a site I have to find a PC with old versions of IE just to test my work before delivering to the client.

    This solution sounds great, I shall test it as soon as I get a chance. Thanks.

  156. Swappy says:

    Hi Guys !
    I have added code for rounded corners to simple html file then added ie-css3.htc file in that file containing folder but works fine on FF and Google-Chrome but when it comes to IE6 It fails. Can anyone of u please tell what kind of changes you have done, other than just renaming the .htc file because after doing that also it is not woking for IE 6.
    One more thing i want to know is this file only working on server other than local machine’s because, i am not uploading anything. just tried for local machine’s following is my code :

    .div
    {
    position:relative;
    -moz-border-radius:0px 0px 10px 10px;
    -webkit-border-radius:0px 0px 10px 10px;
    -khtml-border-radius:0px 0px 10px 10px;
    behavior:url(ie-css3.htc);
    border-radius:0px 0px 10px 10px;
    border:2px solid rgb(151,41,38);
    background:green;
    text-align:center;
    height:50%;
    width:50%;
    }

    12345678910

    All the suggestions are accepted,
    Thanks and regards in advance
    Your friend
    Swappy

  157. Rajeev says:

    Wow
    After searching so many css code finally got a working solution for curved border boxes.

    Thanks bro you are amazing!!

  158. If you are having trouble with combining the border-radius and the gradient filter, try this solution, worked for me. https://github.com/bfintal/jQuery.IE9Gradius.js

  159. Ryan says:

    No matter which HTC file I try, it still doesn’t work!! (ie-css or border-radius.htc)
    I’m runnint IE7 behind an education firewall…haven’t had a chance to test it on a different network.

    I’m about to use nifty corners or something similar as this hack just aint workin….
    I’m trying to combine it with the Jquery for CSS dock menu (http://ndesign-studio.com/blog/css-dock-menu#comment-227470) and just being difficult as usual. If anyone has got this trick sorted before, would love to hear….

  160. Karthik says:

    Hi,

    Is it possible to integrate htc file to a image tag???

  161. Tacit Design says:

    Simply brilliant. Many thanks for posting this.

  162. WisdomSky says:

    wooahhhh… this is what i’ve been looking for 1239403853857190351 years… thank you very much for this article…

  163. rani says:

    hi…

    While using the above method,I am facing lot of z-index issues in IE 7 and IE 8.Please help me

  164. Webdesigner says:

    What if you only want that the top right of your div is round in IE8?
    This code doesn’t work:
    .rounded-corners {
    behavior: url(/css/border-radius.htc);
    border-top-right-radius: 20px;
    }

  165. Josefine says:

    Thank you SO much for this article, you have no idea how hard I’ve tried to make this work. This is great!

  166. Kaushik says:

    I tried to use in my one of project but its not working…

    Make any changes(even add space in html file) and save it…

    Ant then check, It’ll not work in IE7 and IE8.

    Other browser already support radius property.

    I am going on wrong way, or any other reason.. I don’t know..

    Please, give me solution..

    Waiting for reply..

  167. markus says:

    SCUMBAG INTERNET EXPLORER

  168. peak says:

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

    not work on ie8

  169. Asad says:

    thanks for helpful article, i have fixed IE issue for my website :)

  170. wasi says:

    thx, great article

  171. Markus says:

    Hi. Your guide is good. I made it work but when I try it to images it didnt work. What seems to be the problem? How can I make it work?

  172. Damu says:

    how about just two rounded corners? it didn’t work for me in IE <= 8

  173. Avihay says:

    thank you very mach,
    saved me time.

  174. Prakash says:

    Thanks, Your Blog design is Wonderful !!!

  175. Stefano says:

    Ok, this is very cool… but any idea on how to make it work on TABLE and FIELDSET without touching the actual page?

    Thank you so much…
    Stefano

  176. Quran says:

    Thank you for this useful tutorial, I try it my side but without success, may be I will give up for IE7 and even IE8, users have just to follow technology and updates their browsers :)

    Thanks guys
    Quran

  177. Dear … I use ur script (.htc) file , but it is working ok on google chrome and mozila but not working in IE 9.
    Please suggest me …
    for example ..you can run http://www.includehelp.com on different browsers … home page contains ur .htc file
    Regards, SUDHIR SHARMA
    waiting … for ur reply ??

  178. Erika Rendon says:

    Thank you, round corners made my design that much hotter! Thank you so much.

  179. Brad Jones says:

    This was a really great article. Some of us old timers are slow to change. It is more comfortable using the old photoshop cut with the exact look we want. With today’s exploding mobile media using the native CSS to do element effects is so much nicer though as it does not cause the overhead and most of the time the same desktop design scales fine down to the mobile media market as well, saving a lot of time and money to be sure!



Leave a Reply



  • HTML permitted
  • Wrap code in <pre><code></code></pre>
  • Escape HTML to display as text