Skip to the content...

Welcome to the David Walsh Blog. I'm a MooTools, Dojo, jQuery, CSS, and PHP Web Developer located in Madison, Wisconsin, United States. Please contact me if I can make your experience on my website better.

Rounded Corners in Internet Explorer

49 Responses »
Rounded Corners

One of the reasons that I love Firefox and Webkit-based browsers (Chrome, Safari) is the ability to effortlessly create rounded-corner elements using pure CSS:

.round	{ -moz-border-radius:12px; -webkit-border-radius:12px; }

As you probably already know, IE doesn't allow you to create rounded corners without using images or endless hacking. Enter the CurvyCorners JavaScript project. CurvyCorners allows you to quickly create rounded corners within Internet Explorer.

The CurvyCorners JavaScript

<!-- SIMPLY INCLUDE THE JS FILE! -->
<script type="text/javascript" src="curvy.corners.trunk.js"></script>

CurvyCorners detects the usage of "-webkit-border-radius" and "moz-border-radius" on DOM elements and works its magic to duplicate the effect in IE using a series of small DIVs. There are no images involved. You may also identify specific elements to apply rounded corners to:

var settings = {
			tl: { radius: 12 },
			tr: { radius: 12 },
			bl: { radius: 12 },
			br: { radius: 12 },
			antiAlias: true
		 };
/* moooo */
$$('.round').each(function(rd) {
	curvyCorners(settings,rd);
});

MooTools + Curvy Corners

CurvyCorners is known to brick your MooTools code. The trunk code fixes those issues.

Don't let Internet Explorer's refusal to implement rounded corners via CSS keep your websites from being as dynamic as possible! CurvyCorners helps make rounded corners in IE possible!

Discussion

  1. October 28, 2009 @ 8:23 am

    I’m not even going to look at the JS, but I will assume that this applies the table method in IE. Where it makes a table with bordering rows / columns, containing transparent cells that make it rounded. A correct assumption?

  2. October 28, 2009 @ 8:35 am

    @Timothy: Incorrect — no table element involved.

  3. laurence
    October 28, 2009 @ 8:44 am

    Is there an equivalent method for jQuery?

  4. October 28, 2009 @ 8:46 am

    @Laurence: CurvyCorners isn’t framework-specific: it will work with any library.

  5. duncan
    October 28, 2009 @ 8:47 am

    I have the problem on applying padding and embedding multiple rounded corners in i.e, stops allying the inner rounded corners .

  6. laurence
    October 28, 2009 @ 8:49 am

    So I can just amend the

    [code]
    $$('.round').each(function(rd) {
    curvyCorners(settings,rd);
    });
    [/code]

    to
    [code]
    $('.round').each(function(rd) {
    curvyCorners(settings,rd);
    });
    [/code]

  7. October 28, 2009 @ 8:54 am

    @Laurence: Yep.

  8. October 28, 2009 @ 9:38 am

    Also useful for Opera, isn’t it? I’m used to SVG to accomplish it in Opera, but that still doesn’t work for IE (which is the point of your article).

  9. October 28, 2009 @ 9:53 am

    Very nice! I’ve been wondering about “Rounded Corners in Internet Explorer” lately. Do you have any thoughts about Rounded Corners in Mozilla Firefox?

  10. October 28, 2009 @ 2:06 pm

    simple include the file, and it does all the work. brilliant. worked great.

  11. October 28, 2009 @ 3:25 pm

    Why would someone write stuff like this.. Brilliant.
    Haven’t tested it yet, but does it also word on styling just 1 border?
    So if you use things like:

    -moz-border-radius-topleft: 4px;
    -webkit-border-top-left-radius: 4px;
    border-top-left-radius: 4px;

    -moz-border-radius-topright: 4px;
    -webkit-border-top-right-radius: 4px;
    border-top-right-radius: 4px;

  12. October 28, 2009 @ 5:33 pm

    @Rene: Did you only read the title of the post? :P That’s what those settings are all about “tl, tr …” top left, top right, etc.

    I imagine it can auto detect that stuff too just like it auto detects the styles in the first place.

  13. ben
    October 28, 2009 @ 6:51 pm

    Nice! BUT… just had a look at the generated code in the IE Developer Toolbar.. there’s hundreds and hundreds of DIVs been generated there, a lot of them with IE filter styles. This can’t be great for performance?

  14. olivier refalo
    October 28, 2009 @ 8:22 pm

    My rule of thumb. Use extended features for WebKit & FireFox.. leave the other browsers display is as is, without the fancy styling. In the end, users will switch to browser they like the most…

  15. October 28, 2009 @ 11:21 pm

    Thanks much for this!

  16. October 29, 2009 @ 4:25 am

    Shouldn’t we just ignore IE cssroundedcornersfail and accept the lack of CSS3 support? All that JS! In that way people will never understand the difference in browser quality…

  17. dejan
    October 29, 2009 @ 4:27 am

    As from 2.0.x, CurvyCorners allows you to put rounded corners on your page elements using CSS. No need for javascript.

  18. anders ringqvist
    October 29, 2009 @ 6:18 am

    My eyes!!! It´s burning >.< damn, shouldn´t have looked at the generated code. It´s so fubar.

  19. vsync
    October 29, 2009 @ 6:45 am

    from my vast experience with many “round corners” making scripts,
    DD_Roundies is the best solution.

    http://www.dillerdesign.com/experiment/DD_roundies/#nogo

  20. October 29, 2009 @ 10:37 am

    I’ve used curvey corners for IE and I like it. Though the main problem I have is when you rounding a corner on a container you want to be clickable then any JS rounded corner fix messes things up.
    I’ve seen a tutorial for Opera rounded corners that used SVG and I’m wondering if maybe something similar could be used for IE (i think it uses VML not SVG mind you).

  21. October 29, 2009 @ 11:03 am

    I agree with vsync, DD_roundies, work very awesome. Not sure if its the fact that they have been around a while or not. Bonus of DD_roundies, that the library fixes transparent PNG loading in IE, and seems to be fastest one around.

  22. October 29, 2009 @ 11:29 am

    IMHO if IE can’t handle rounded corners – then I don’t see why we should be cluttering up the code and spending any extra time.

    Like anything – this technique will be handy in the real world where some clients will insist on rounded corners in all browsers. Then it is balance between using this technique and any other that there may be floating around.

    Good work. But not sure I’ll be using it anytime soon – unless I really need to.

  23. jesse
    October 29, 2009 @ 11:52 am

    I agree with oliver and anders, the code is a bit frightening. I was trying to use this library for a javascript web app, which it used to generate about four or so rounded containers and maybe 10 or so rounded buttons. The performance got pretty laggy with all that extra code getting injected. If you’re going to use it for just a few containers, it’s great, but any more than that I would just use PNG images and a PNG-fix script for IE.

  24. October 30, 2009 @ 2:49 am

    This is something which I was Looking for a long time.
    Thanks buddy for posting this, I usally dont search, but I did — I found this. Extremely Happy.

  25. October 31, 2009 @ 6:34 am

    Agreed, DD_Roundies is the best solution out there. Don’t even bother playing around with any other scripts.

  26. October 31, 2009 @ 7:44 am

    I recall using DD_Roundies and them messing up the position of an element.

  27. sebastien brault
    October 31, 2009 @ 8:58 am

    please don’t use this!!
    use standard CSS for standard compliant browsers, let IE fail (it’ll just display square corners).

    Rounded corners are trivial and don’t justify kilobytes of javascript or absurdly complex markup and slow-down performance.

  28. October 31, 2009 @ 9:01 am

    @sebastien brault: “Let IE Fail”…that’s ridiculous. While I agree that rounded corners are trivial, would every client believe so? Probably not.

  29. October 31, 2009 @ 9:16 am

    Great tip, I will be implementing this solution on one of my projects this week!

  30. sebastien brault
    October 31, 2009 @ 9:22 am

    @David Walsh: “Let IE Fail”…that’s ridiculous.
    If you HAVE to use rounded corners, using background images still seems more reasonable to me, both from page-load performance and markup coherence stand-points.
    But if the “solution” is to load hundreds of lines of javascript code that generates absurd html markup, I would much rather try to deliver web layouts that avoid using rounded corners and don’t sacrifice meaningful markup.

    I just hope web designers don’t start implementing this “solution” all over the place without considering the draw-backs, because they are huge.

  31. josefina
    November 4, 2009 @ 8:11 pm

    @olivier refalo: you will loose clients with that rule of thumb!

    In my opinion applying JS for styling is just not right. Performance is very important in big sites! Of course if you are developing a site for your little sister then you dot think too much about pixel perfect and cross browsers implementation problems..but talking seriously, this is not the way to go! not JS or behaviors for CSS! they just slow down the loading of your site.

  32. November 5, 2009 @ 7:00 pm

    Reading this conversation, I am really surprised. Think about it, if you want to let IE fail then doesn’t that include not caring about performance in it? If your site loads a tad slower with this script in IE, then hell let it be. Even though JS shouldn’t be used for styling, it SHOULD be used for fixing stuff for older/non-standard browsers. There are many like HTML5 Shiv, PNG Fixes, etc so I don’t really see a problem with this one.

    Personally, I would put this within conditional tags for IE, and use php for opera detection. This way modern browsers would not suffer for IE/Opera.

  33. November 15, 2009 @ 8:20 am

    Wow this is cool. I just hope this js won’t eat up the users pc resources. I have a pretty cool design on one of my websites but in IE looks like a shit only because of the inexistent rounded corners (yep I was little bit lazy to create that rounded img).

  34. December 16, 2009 @ 10:15 am

    I’m going to stick with the traditional use of images until CSS3 is fully supported, may I also like to add that what if javascript was disabled? Alot of people browse with it turned off, images in my opinion seems tidier and works for everyone.

  35. anders lindén
    December 31, 2009 @ 7:23 am

    Unfortunately, when this webpage was loading, the corners were straight for a while. I cannot use that…

  36. February 18, 2010 @ 5:31 am

    Dave, first of all, great site. For not being a designer you’ve done good work here.

    Question 1: Do you think it’s possible to create a gradient background within these rounded corners?

    Question 2: I’ve searched through your site, and I cannot figure out if you’ve explained what you use to create your section tabs interface.

    But man, great site, amazing information.

  37. February 24, 2010 @ 6:01 am

    You are my hero, I’ve spent a day looking for a solution that works in IE and there are dozens out there. Most involving tons of additional divs, images, even hacked about with jQuery.

    I was at the point of just using the border radius and ignoring IE users when I found this post. Brilliant, elegant, clean and simple.

  38. gino
    February 26, 2010 @ 5:57 pm

    Hi, what i don’t like with these corner that it only load after the page have fully loaded, if a page is slow to load these corner will not appear.

  39. s
    March 10, 2010 @ 8:37 am

    @gino: This is because with DOM the elements that will be styled by JS need to be rendered on page before it can affect them. You’d need to hide the page content first, then after the corners are in place reshow the page contents (a whitewash effect)… or wait for IE9.

  40. March 16, 2010 @ 10:08 am

    This is great, but how do I turn off the css auto-detect? I only wish to apply it manually to a couple of core areas in IE …

  41. April 13, 2010 @ 11:01 am

    “Don’t let Internet Explorer’s refusal to implement rounded corners via CSS keep your websites from being as dynamic as possible!”

    This is the stupidest thing I’ve ever heard. Please tell me how rounded corners makes a site “dynamic”?

  42. June 4, 2010 @ 8:19 pm

    @David Walsh: thanks

    its very nice and help.

    canu send me diffarent sahdes, and text grdiant and grediant effect

    Thanks

    sandeep

  43. June 13, 2010 @ 6:02 pm

    @David Walsh: I agree there are times when a client will insist on a consistent look through out all browsers.

    However….

    @sebastien brault: the developer in me agrees with you, I would like nothing more than for IE to fail OR get their act together.

    Seems like I have been waiting for them to get their act together for a long time not sure if it will ever happen, so now failure would be nice. IE8 is a huge improvement, but they are already getting behind as more and more of us are push html5 coding into the limelight…

  44. mark valdez
    June 15, 2010 @ 9:31 pm

    I like this JS you created, but it seems so heavy when loaded in IE browser. Good effort though, but I rather use rounded image..that way it will load faster and design wise it looks neat and clean.

  45. June 16, 2010 @ 10:32 am

    Interesting posts. If you’ll forgive the plug, I generated my own approach to IE-friendly curvy corners using a mix of JS and PHP GD. Here’s the project – it’s free, I don’t get any more for it, just sharing it. Cheers.

    http://mitya.co.uk/scripts/curveMe—cross-browser-curvy-corners-107

  46. oussama fadlaoui
    June 25, 2010 @ 4:59 am

    Honestly, You’ve got the best website I’ve ever seen in my whole career. Your tutorials are stunning. I really want to thank you for all your help. I really appreciate this.

  47. rob blinzler
    June 28, 2010 @ 2:36 pm

    This works great for me, with one exception – gradient background – which breaks when I use this script.

    I’m using a filter to get a background gradient in the same element I want rounded corners, and I’m getting a blue solid background when I implement the script.

    Any suggestions?

  48. June 28, 2010 @ 3:13 pm

    @Rob Blinzler: hey – are you referring to my script?

  49. rob blinzler
    June 28, 2010 @ 7:29 pm

    @Andy: No, actually I’m developing on Asp.Net. I was referring to David Walsh’s.

Be Heard!

Share your thoughts with fellow developers of all skill levels! I want to hear from you!

Name*:
Email*:
Website:  
Wrap your code with <code> tags, f00!