November 2007
Posted on the 15th at 7:35 PM CST
How to Create Fluid-Width <div> Layers with Rounded Corners
FiledFiled under CSS, Standards

Rounded corners are pretty awesome, and I have no idea why. Is it becuase they are not the easiest things to produce? If it were simple, would they be as popular? Who knows. In a world of squares, rounded corners are like hot chicks. They're attractive, appealing, beautiful, and everyone wants to have them. So I guess today I get to play the role of a rounded corner pimp, and I am not charging a dime. I will demonstrate how to create these lovely layers with rounded corners that all the poor beveled boxes in the world envy. And I am taking the fluid-width approach because wasting screen real estate is a sin. Anybody with a little CSS knowledge, some patience, and a keen eye can make this happen rather easily.

You do not need to purchase an expensive imaging suite to do this. I would highly recommend Paint.NET, which is a wonderful open-source project written in C#. Overall, it's a very impressive program. If you are a Mac user, it sucks to be you you will have to go with GIMP, that is unless you do not have Adobe Photoshop installed already. Obviously Photoshop rules all imaging programs, but I will be demonstrating with Paint.NET because it's free for all. Here is the game plan...

  • Draw a filled rounded rectangle of any size on a transparent background.
  • Add a shadow type effect to add some distinction to the edges of the shape.
  • Precisely crop out the top left, upper right, and middle left areas of the shape.
  • Produce the other required sections by rotating the canvas of those three images.
  • Develop the markup and corresponding CSS needed to comprise the final result.

Before I go any further, I must mention that I will be using the wonderful PNG image format with alpha transparency. Alpha transparency is wonderful becuase it has the ability to accurately blend with whatever is behind it. This offers quite a bit of flexibility. However, the downside to this is that older browsers such as IE6 do not support this format very well. In IE6 specifically, all PNG images with transparency will be given an ugly gray background. You can see an example of this by viewing my blog in IE6. There is a fix by Angus Turnbull that corrects the problem for IE. I don't use the script on this site becuase I feel that IE6 is ancient; it is time for us to move on, dammit.

Creating the Shape in Paint.NET

Open up Paint.NET and create a new image, it does not have to be huge. Before drawing a shape, Select All (Ctrl + A) and erase the selection by pressing the Delete key. This will give you a transparent background, which is generally represented by gray and white checkerboard. Paint.NET always defaults to a solid white background, and I don't know how to change that.

Now you can draw the shape; Paint.NET has a rounded rectangle tool that makes this pretty simple. You'll want to make a decision on which color to use first, I chose to use a shade of blue. For this blog, I went with White and low opacity (I will get to that in a minute). Select the Rounded Rectangle icon from the box of tools, and set it to draw a filled shape, as illustrated below...

Draw Filled Shape

Now you can draw the shape. Size does not really matter at this point because we are going to be stretching the parts of the image as needed.  Here is what my shape looks like...

View of my Rounded Rectangle

To add some distinction to the edges of the shape (optional), I will use Paint.NET's Unfocus effect, which can be found in the Effects menu, under the Blur category. Any value from 1-6 should be fine. The unfocus effect will blur the edges in with the background. Since I am using a transparent background, the edges will blur with anything that ends up underneath it, which is exactly what I want. Here is what it looks like unfocused...

View of the Unfocus Effect in Paint.NET

Semi-Transparent PNG Images 

I am not going to be doing this in my example, but I want to show you how to make the whole image semi-transparent, just like I use here on my blog. It is really simple to do in Paint.NET, like most of the things illustrated here are. All you need to do is press F4 on the main shape, and that will bring up the Layer Properties window. You can drag the opacity lever to your liking and you will start to see the gray checkerboard come through the entire shape. The lower the opacity, the more transparent the image becomes. Easy as that! The fantastic PNG format takes care of the rest.

It's very important than you are comfortable with the shape you have created before moving on. We will be cropping out parts of the picture in order to get this design in HTML format, and it is practically impossible to make modifications to the final shape after you have cropped everything. You would pretty much have to start over from scratch. Adobe Photoshop has features to help resolve this, but that comes with a price tag. So, make sure you like how it looks before forging ahead. If you need to, just save the whole shape as a PNG and experiment in an empty web page with other background colors.  Do whatever you gotta do to be completely satisfied with it.

Crop it, Save it, Flip it, Save it

Here comes the tricky part. To produce the fluid-width layout, I will be using what is called the sliding doors approach. We have to select the top, the left, and the top-left sections of the shape, making sure that the borders will line up when cascaded.  Having a transparent background does not make it any easier (on the eyes, at least). I always begin with the upper left corner, you want to make sure you select enough of it so that there is a smooth transition between the rounded part and the straight part. I usually zoom in to about 1200% to do this. Take the rectangle select tool and start at the first pixel that clears the "curve" effect on the bottom left side of the upper left corner and drag it upwards and to the right...

Where and how to select the top left corner

As you can see in the image, Paint.NET keeps a history of your steps so if you mess up during the selection, you can easily step backwards (Ctrl + Z) and try over. Make sure you have selected all of the "fading" pixels of the corner. Now you want to go to the Edit menu and choose Cut (or press Ctrl + X). Then choose New from the File menu (or press Ctrl + N). The program will automatically set the dimensions of the new image based upon what you have on the clipboard. Choose OK. Before you paste, make sure you do a Select All (Ctrl + A) and press the Delete key to start off with a transparent background (again). Once you have your transparent background, go ahead and paste the image. Now save it by choosing Save As from the File menu (duh)...

Save the image

You will want to select PNG as the file type. I always name these files as abbreviations for their location within the shape. So the top-left piece is "tl.png", the left piece is "l.png", the bottom-right piece is "br.png", etc. If a background image is necessary for the main part, I name it "bg.png".

We can easily re-use this top-left image for the bottom-left by flipping it vertically. This will maintain strict consistency between the dimensions and position of both shapes, and will more importantly save us some time. Once you have saved the image, choose Flip Vertical from the Image menu. Do another Save As and name it "bl.png".

And now we have our top and bottom left corners and they are ready to use. Keeping in mind that I am taking the fluid-width approach, the top-right and bottom-right pieces are going to have to be very wide to accomodate all of the modern screen resolutions. I would target the maximum width of the final shape to be at least 1600 pixels, especially considering the increased popularity of widescreen monitors. For this example, I am aiming for 2400 pixels. Since the upper and lower left images are 12 pixels wide, the upper and lower right images will need to be 2388 pixels (2400 minus 12), and both of the images should be 12 pixels in height. So, get back to the original shape in Paint.NET (you can exit or press Ctrl + Q to bring up the Image List). Select as much of the top right section of the shape as possible, using the slice from the previous cut as a guideline...

Selecting the Top-Right Section of the Rounded Rectangle

Drag it slowly across the screen until you reach the other side where the top right corner of the shape is.  Be consistent with your selection; try hard to recall how many pixels of whitespace you selected outside of the shadow (if any) on the top-left corner. Now you want to do another Edit | Cut and then File | New.

Before deleting the white background and before pasting the image on the clipboard, we need to make the image canvas very wide to accomodate for all modern screen resolutions (fluid-width, remember?). To do this, select Canvas Size from the Image menu (or press Ctrl + Shift + R). As previously noted, this image will need to be 2388 pixels wide...

Change Canvas Size

And now, once again, do a Select All and press the Delete key to get a transparent background (it's an easy step to forget, trust me). Go ahead and paste the image and drag it to the right edge. Make sure you are precise in the positioning against the right edge, it needs to be consistent...

Moving Top-Right Section Against the Right Edge

Now choose Deselect from the Edit menu (or press Ctrl + D). It is fairly easy to stretch sections of an image in Paint.NET; just select the chunk that can be horizontally repeated without distortion (obviously do not include the corner), and then click the "Move Selected Pixels" tool to make then resizeable "nubs" appear...

Use the Nubs to Resize the Image

Now just grab ahold of the middle nub on the left edge and drag the selection all the way across to the end of the canvas. After you have stretched it, scroll back over to the right edge and make sure the corner still looks alright. If everything looks good, do a Save As and call it "tr.png". Just like before, choose Flip Vertical from the Image menu and do another Save As and call it "br.png".

Phew, the hard part is done. It's pretty much mooth sailing from here on out. Go back to original shape in Paint.NET. All we need now is a chunk of the left edge. I usually include one pixel of the shapes core color with the left image...

Selecting the Left Section of the Rounded Rectangle

You might be thinking "why select so much?" or "why not just select one pixel of height for the left edge?" and there is a reason. Some browsers do not handle the PNG format too well. If you have a ton of them repeating, the browser tends to have noticeably slow response. A 20-30 pixel chunk can make a lot of difference, and the file size will not be that much larger. I chose to select a piece of the left edge 30 pixels in height. Follow the same pattern as before; Edit | Cut (or Ctrl + X) and then File | New. Do a Select All (Ctrl + A) and press Delete to get a transparent background. Paste the image and save it as "l.png". This time select Flip Horizontal from the Image menu and save it as "r.png".

The following is not really necessary for this particular example, but I am going to demonstrate it anyways because if you are using a modified opacity level (like I do on this blog), you will need to use a background image to make up the center part (the body) of the shape. To do this, simply select a chunk in the middle of the original shape and follow the normal procedure for saving it as "bg.png". I used a 50x50 chunk for the background image in my example. And now it's time for the fun part!

The Almighty <div> Tag

In order to layout all of these images and create a markup-based shape, we will need to use a series of <div> tags. CSS will be used to position the tags and set the background images. Here is the general markup structure...

<div class="rounded">
    <div class="top"><div class="right"></div></div>
    <div class="middle"><div class="right">
        <div class="content">
            <!--Content goes here-->
        </div>
    </div></div>
    <div class="bottom"><div class="right"></div></div>
</div>


The first <div> is the wrapper. It is immediately followed by the top section, the middle section, and the bottom section. Each section must immediately contain a child <div class="right">, which will essentially make up the right edge of the shape. This is a perfect structure for the fluid-width layout. Last thing to do is develop the stylesheet, which is really the brains of the whole operation.

Bringing it all Together with CSS

Here are the goals we need to accomplish with CSS for each <div> tag...

Wrapper
The wrapper class will control the positioning, the outer margins, and the width of the entire shape. For fluid width, we want to use a high percentage. We also want to set a max-width value to the maximum possible width of our shape (2400 pixels, remember?), so that things can not possibly get ugly. It also needs to clear from both the left and the right.
Top
This will contain the top left background image and will have a 100% width (the actual width will be inherited from the wrapper).
Top Right
This <div> contains the extra-wide background image. To make this image work the way we want, we need to anchor the background position to the top-right. This <div> will also set the height for the top section, which will be the height of each background image (12 pixels). A left margin is also necessary to accomodate for the width of the top left background image contained in the parent (again, 12 pixels).
Middle
This will contain the left background image, which will need to be repeated vertically (on the y-axis). This will also be 100% width, and it needs to clear from any other elements to the left or right of it.
Middle Right
This contains the right background image (again, repeated on the y-axis), and accounts for a small margin of 5 pixels for width of the background image contained in the parent.
Middle Right Content
This will be the container for the content of the final shape, and will contain the background image ("bg.png") if necessary. It will set the font, color, text alignment, and line height. Padding to the right is needed to accomodate for the middle-right background image. Also, child elements of this <div> such as <p> and the <h1> will need to be styled to suit your needs. Practically anything can go inside of this layer.
Bottom
This will contain the bottom left background image and will have a 100% width. As with all other "sections", it needs to clear from any other elements to the left or right of it.
Bottom Right
This is very similiar to the top-right section, except the background position should be anchored to the bottom right. Everything else is the same.


I think that should be enough explanation to make this understandable. Time to get down to the code. You just gotta love this part...

div.rounded {
clear:both; max-width:2400px; margin:5px auto; width:95%; } div.rounded div.top { background:url(../images/tl.png) no-repeat bottom left; padding:0px; width:100%; } div.rounded div.top div.right { background:url(../images/tr.png) no-repeat bottom right; height:12px; margin-left:12px; } div.rounded div.middle { background:url(../images/l.png) repeat-y left; clear:both; width:100%; } div.rounded div.middle div.right { background:url(../images/r.png) repeat-y right; margin-left:5px; } div.rounded div.middle div.right div.content { background:url(../images/bg.png) repeat top left; color:#fff; font-family:"Trebuchet MS", Calibri, Tahoma, sans-serif; font-size:1.0em; line-height:1.3em; margin-right:5px; padding:0px 7px; text-align:justify; } div.rounded div.middle div.right div.content p { margin:0px; padding-top:15px; } div.rounded div.middle div.right div.content h2 { color:#0f2; font-size:1.75em; font-weight:bold; margin:0px; padding:7px 0px; } div.rounded div.bottom { background:url(../images/bl.png) no-repeat top left; clear:both; padding:0px; width:100%; } div.rounded div.bottom div.right { background:url(../images/br.png) no-repeat top right; height:12px; margin-left:12px; }


And that's really all there is to it. Not too shabby, eh? I have setup a demo page for you all to go check out. It has the final result on it and you can change the background color to see how flexible the fade effect is (thanks to PNG). I also have everything available for download in a zip file. Enjoy!

  View the Demo
  Download rounded.zip (7kb)

If you have any confusion about how this works, feel free to ask me a question. If you have any comments or suggestions, I would love to hear them as well! Just use the form at the bottom of this page.

Have fun!

Comments (65)
Permalink Comment from Peter Kellner on November 16th, 2007 at 12:17 AM
very nice article. I need to learn this program. I've avoided learning photoshop my whole life (partly because I never bought it)
Permalink Comment from Josh Stodola on November 16th, 2007 at 6:48 AM
Thanks Peter!

I got Photoshop CS2 over a year ago, and let me tell you, it is very overwhelming. The capabilities are unprecedented. It is rather expensive, but considering how powerful it really is, it could be pricier. Unless you do a significant amount of work with images/photos, I probably would not recommend getting it, mainly becuase it is not a program you can hop on and figure out in a few moments time. It takes quite a while to learn. I only use it to do the basic things, which I can say first-hand does not make it worth the price.
Permalink Comment from ScottJ on November 19th, 2007 at 12:22 PM
Very well written article. I was playing around with VS2008 the last couple of weeks and was just about ready to start looking for the best way to do rounded corners w/o tables. BTW, I'm from NE but moved to MN (around Brainerd) a few years back. My brother and sister live and work in Lincoln. Go Huskers!
Permalink Comment from Robert S. RobbinsEmail on November 19th, 2007 at 1:42 PM
I think you should learn Photoshop no matter how long it takes. I frequently see Photoshop experience listed as a required skill for programming and web development jobs. Like it or not, it makes you look unprofessional to be Photoshop ignorant. Personally, I prefer Corel Painter 8 for its realistic artist tools and superior creative experience.

I hope your rounded corner technique works with my Microsoft Expression Web template. I've tried two other methods without much luck.
Permalink Comment from Josh StodolaEmail on November 19th, 2007 at 2:11 PM
@ Scott

Thank you very much. It is GREAT to hear from a former Nebraskan and a Husker fan! I live and work in downtown Lincoln as well, and I must say it's been a rough year for us so far. But you know we will never stop cheering for them! I'm just glad they got that clown Pederson out and brought in Dr. Tom as the interim AD. Hopefully he will stick around.

@ Robert

I fully agree with you. Having an understanding of Photoshop is a very noteworthy skill for any web developer. I am definitely glad that I can say that I own Photoshop and can maneuver my way around it. But for the majority of developers, it is far more powerful than they need. Which is why I chose to demonstrate with Paint.NET. But, for anybody doing some serious graphics work, Photoshop should be a pre-requisite.

If either of you run into problems, feel free to ask me anything.
Permalink Comment from Robert S. RobbinsEmail on November 19th, 2007 at 3:56 PM
Thanks! This technique worked for me even though I had some floats to deal with and Firefox issues. I'm trying to create a site that can be redesigned entirely through CSS like the famous CSS Zen Garden site.
Permalink Comment from Wayne on November 19th, 2007 at 3:59 PM
Good article!

I've used a similar approach that doesn't require the "long" piece, but does require an extra nested div and add'l images for the top and bottom edges, something like...

.roundedTop { background: url(top.png) repeat-x; }
.roundedTop div { background: url(tl.png) no-repeat left; }
.roundedTop div div{ background: url(tr.png) no-repeat right; }

<div id="myRoundedBox">
<div class="roundedTop"><div><div></div></div></div>
...

Also, note that the class names do not need to be specfied on the child divs due to the way the styles were defined (a little bit of a typing saver)
Permalink Comment from Josh StodolaEmail on November 19th, 2007 at 5:00 PM
@ Wayne

Thanks! I did consider that approach but I ended up settling with this becuase it is less images and less div tags. It really is a personal preference, and I am glad that you pointed that out.

You certainly make a point about the class names of the inner divs. I instinctively over-specify when it comes to CSS. I guess historically I have ran into so many inheritance issues with CSS that now I tend to overkill a little bit. Oh well, keep in mind that those class names serve as self-documentation and help make this a little easier to understand how it all comes together.

Thanks for the comment!
Permalink Comment from richard on November 20th, 2007 at 6:17 AM
Can someone explain where this method fits in (i.e. pro's and cons) with other methods such as CSS and javascript (http://www.html.it/articoli/niftycube/index.html). I'm not sure which way to go here
Permalink Comment from Josh StodolaEmail on November 20th, 2007 at 7:39 AM
@ Richard

The benefit here is that it's a much more lightweight solution, meaning it will load quicker in the browser. Nifty corners also do not get applied until after everything on the page has loaded, which could cause quite the delay depending on the size of the site.

And this is just my opinion, but the fact that hundreds of small <div> tags are being generated and tossed into the DOM on every single page load just does not sit well with me. I believe the method illustrated here is much more efficient.
Permalink Comment from richard on November 20th, 2007 at 10:05 AM
Thanks Josh, if this is the recommended method then this site http://www.neuroticweb.com/recursos/css-rounded-box/index.php
may be of use (save messing about with the graphics bit)
Permalink Comment from AllAboutTheTables on November 20th, 2007 at 3:39 PM
3x3 table with corners works for me!
Permalink Comment from Josh StodolaEmail on November 20th, 2007 at 4:16 PM
Well goody for you. If you prefer an unorganized and jumbled mess of markup that is a wasteful eye-sore, that is your prerogative.
Permalink Comment from FZ on November 21st, 2007 at 10:58 PM
Why does not CSS support roundcornered div like this <div style="border:roundcornered radius=5"></div>
Permalink Comment from Josh StodolaEmail on November 22nd, 2007 at 12:31 AM
That truly is a great question! And I think that when CSS version 3 is released (scheduled for sometime next century, I believe) then we can do it that way. I have been waiting for it for many years now, and I still have patience. It's all I can do. Have high hopes, my friend! Until then, we gotta do it the "hard" way.
Permalink Comment from Sprogz on November 22nd, 2007 at 12:29 PM
Yes, CSS 3 will remove the need for all these div and img shenanigans!

border-radius:1em for example will set rounded borders. In the meantime you can give Firefox users rounded corners with -moz-border-radius and add border-radius beneath the rule so that when Firefox X and IE 8+ catch up with CSS 3 they'll all play nice.

See http://virtuelvis.com/download/218/border-radius.html
Permalink Comment from Josh StodolaEmail on November 22nd, 2007 at 12:35 PM
Thanks for the link, Sprogz! I am really looking forward to the new versions of CSS and ECMAScript (Javascript). Now, back to the Packers/Lions game.

Turkey is served in 45 minutes! HAPPY THANKSGIVING!
Permalink Comment from Thom on November 24th, 2007 at 1:13 AM
Thanks for the detailed and entertaining walk-thru of how this works. The web is great and you have made it better with your site. I've read other explanations and approaches but your was...well... much more approachable. Thanks and keep up the good work.
Permalink Comment from Josh StodolaEmail on November 24th, 2007 at 12:41 PM
Thom- thank you so much for the very kind comments! I am thrilled to hear you enjoy my blog and benefit from it.
Permalink Comment from SeanEmail on November 26th, 2007 at 10:25 PM
That's pretty cool. I noticed that the AJAX Control Toolkit has an extender that does a similar thing. I wonder how your techniques differ.

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/RoundedCorners/RoundedCorners.aspx

Permalink Comment from Some.NET(Guy) on November 27th, 2007 at 2:45 PM
Personally, I'm not a fan of empty divs, which your code abuses. Sure, you could put in 100 empty divs and call it div structure, but what are you really gaining? The whole point of div structure is semantics. By inserting empty divs, you're essentially doing the same thing as someone who is using tables.

I wrote a tutorial in a blog I kept a while ago about how to do this in the most effective way. You should check it out :)

http://fixmysite.blogspot.com/2006/06/tutorial-semantic-liquid-rounded.html
Permalink Comment from Some.NET(Guy) on November 27th, 2007 at 2:48 PM
Oh, also... I forgot to mention... pngs are about 3x to 4x the size of gifs/jpgs, which is why it takes your site about 25 seconds to load on my comp with a cable connection. But yeah, they do make things look nice :)
Permalink Comment from Josh StodolaEmail on November 27th, 2007 at 5:02 PM
@ Some.NET(Guy)

You make a very good point about the empty <div> tags. There might come a point in time where empty tags are ignored by the browser, so I will definitely take that comment to heart. I actually cannot believe I did not consider this already. Thank you very much for bringing this up (thanks for the link, too, it was quite helpful).

As far as the PNG file size, they are actually not that bad. GIF images are not as small as you might think. PNGs are only a slight percentage larger, in most cases. And we can throw JPEG right out of the window becuase of the poor of quality (due to lossy compression). The powerful capabilities of the PNG in conjuction with the magnificent quality make it the best choice for any and every web image, IMO.

And for the record, the reason it takes this blog a while to load has nothing to do with the image format. It is because of my slow server. I host this blog myself so bandwidth is quite limited.

Thanks a million for sharing your thoughts!
Permalink Comment from Some.NET(Guy) on November 27th, 2007 at 6:45 PM
Wow, self-hosting...that's ballsy :)

pngs and gifs are approximately tantamount in size when the transparency feature of the png isn't used. As soon as you turn that on, the size shoots through the roof (relative to the same image in gif format). Of course, you can do a lot more w/a png, but IMO if you aren't using the transparency feature, there's absolutely no reason to use a png, especially since they aren't 100% supported by all browsers.
Permalink Comment from Chad Smith on November 28th, 2007 at 6:44 AM
It's a shame people fail to take the middle ground more often. Those berating the overzealous use of divs are correct in that that's not what divs are intended for (breaking semantics) but wrong (usually) in their conviction that nice layout can and should be done with divs, the truth is, that html is still lacking the markup it should have for relatively complex designs and when that does come, divs will be added to list of html elements like table that are used when they shouldn't be.

The second comment I have is on the reason given for not using a javascript based rounded corners approach which is given as truth but is infact subjective. Javascript rounded corners are added after pageload, which does cause a flicker and an inconsistency whilst loading. This however is very much inline with how many sites would priotitise; content first, looks second. If the rounded corners don't load, big deal. Also, this approach is much closer to what will happen with the css3 spec and so has that as a benefit (remove an ajax extender, add a style rule, as opposed to remove a dozen containing divs and add a style).
Permalink Comment from Josh StodolaEmail on November 28th, 2007 at 7:30 AM
I agree with you Chad, except I don't feel that HTML will be changing at all. CSS will be what is changing (as you went on to mention). Even when CSS3 does make a presence, there are still going to be cases when you will need to use images to produce the rounded corners you wish to have (like on this site, the layers with rounded corners have a small shadow around them).

You made a good point about how easy it will be to change to CSS3 with the AJAX method as compared to this method. Thanks for the comment!
Permalink Comment from Matt Shirey on November 29th, 2007 at 7:20 AM
Great article. I'm fairly new to ASP.NET and I have been toying around with DotNetNuke and I like the ease but it's to much of a "cookie cutter". I really like how you did your site.

If you have any pointers you can give me on how to make such a clean site like yours, I would greatly appreciate it. jmattshirey @ yahoo dot com .
Permalink Comment from Jing PolsEmail on November 29th, 2007 at 11:05 PM
Hello ALL! I am so happy to be here learning to the .Net WORLD! Thanks for all the Information you've shared, I really appreciate it!!!!
Permalink Comment from Thom on December 1st, 2007 at 3:58 PM
Two more questions:
How would you create a version of this that uses a gradient background? Can you walk thru the steps in Paint.net?

Two: Since the Paint.Net code is under an MIT license wouldn't it make an interesting project to put up a web interface that spits out different types of boxes depending on the user input. The input parameters would be boxType (rounded, square), size, fixed or liquid, color, bordercolor, bgcolor, gradienttype, transparency etc.
Permalink Comment from Josh StodolaEmail on December 1st, 2007 at 4:51 PM
Hi Thom,

All the effects you see on this site were done using Adobe Photoshop. While I know Paint.NET has a gradient effect, I do not really know how to re-create what I have done here. When I get some free time I will mess around with it and see if it can be done.

Your second thought is rather interesting. I think it's a pretty good idea. Care to build it?
Permalink Comment from Thom on December 2nd, 2007 at 10:54 PM
I don't have the skillset to do this. I would possibly be able to do some directed beginner level work in C# but not much in the way of real work.
Permalink Comment from Koen on December 12th, 2007 at 3:01 AM
Sadly the transparent PNG's look really ugly in IE6 (displaying on a green or gray background depending on the color depth), unless you load them with the so-called PNG-fix IE alpha load filter thing. And IE6 is not yet out of the question. Will be another 1 or 2 years.

Obviously don't bother if you don't want to...
Permalink Comment from Josh StodolaEmail on December 12th, 2007 at 5:14 PM
Yeah, I have decided to give up on IE6 users even though there are still an astonishing abundance of them. I guess they are going to have to live with it and continue to miss out on the finer things of the Internet. It is their choice, really.
Permalink Comment from SeanEmail on December 18th, 2007 at 12:24 AM
I just used this method to make a Word Bubble of variable size. Nice.
Permalink Comment from Josh StodolaEmail on December 18th, 2007 at 9:43 AM
Nice! This approach really is applicable to ANY type fluid-width container structure that is comprised of 6 images (some slight modifications to the CSS will be necessary, but the core structure should remain the same).
Permalink Comment from SeanEmail on December 19th, 2007 at 9:57 AM
Unfortunately, I had to revert to using (urgh) a table structure due to truly awful HTML/CSS support on email clients. (And, even that isn't working too well in Outlook 2007. Someone needs to slap MS upside the head for switching the Outlook 2007 rendering engine to MS Word. WTF?)

My research tells me that everyone should use Mozilla's Thunderbird client. Otherwise, we're stuck in the dark ages in terms of HTML/CSS support in email.
Permalink Comment from Josh StodolaEmail on December 19th, 2007 at 12:45 PM
The standardization of email markup has been an issue that seems to live on the back burner. However, Zeldman recently brought the topic back up a couple weeks ago (http://www.zeldman.com/2007/11/28/give-html-email-a-chance/) so I think this problem is finally starting to get some recognition.

Have faith, hopefully with time email clients will also start to adopt the standard and we can all be happy. You can help: http://www.email-standards.org/
Permalink Comment from Dave on January 17th, 2008 at 12:10 PM
This is a nice solution and props to Josh!

My perennial trouble though is I build commercial sites that even now (I remember the bad old mid-90s days) have to be consistent across browsers. So I will have to browser-sniff and serve up different pages or layouts.

Obviously not by choice, but trust me, we are still stuck in the mess of mixed-standards... and as Sean said, e-mail HTML rendering, don't talk to me about that GRR :)

Anyway, sweet code sir!
Permalink Comment from Josh StodolaEmail on January 17th, 2008 at 5:14 PM
Thank you very much, Dave! For the record, this rounded corner method/layout should still work in old browsers, you will just have to use a different image format. It's the alpha transparency feature of PNG that causes problems.
Permalink Comment from leonardbadi on March 6th, 2008 at 9:51 AM
Fantastic tutorial!!!! Thank you very much. I was wondering if it is possible to use some of the pictures on your blog on my web site? I am not a web developer, not even a designer. I am busy redesigning my site. I am working with Dreamweaver.Thank you once more.
Permalink Comment from leonardbadi on March 7th, 2008 at 2:24 AM
Thank you very much for coming back to me. I understand your position and appreciate your willigness to help me. If you don't mind I will go step by step.
1. Background Image: it looks like it is a full picture. How do you insert in the background and still get your site to load quick? I am used to take a 1px sized image and repeat it. How do you do it?
2. To keep corners of all your rounded boxes identical, do you make one set and then fill them with different color or do you make as many images?
3. How do you make that small tip pertruding on the box?
Sorry for asking so many stupid question.
Regards,
Permalink Comment from Josh StodolaEmail on March 7th, 2008 at 5:14 PM
Hi Leonard!

1) The background image is in a JPEG format, which has lossy compression. If you look closely you will see areas in the image that are somewhat blurry. I chose the best JPEG quailty preset that was the perfect compromise of quality and file size. The final size of the image is about 142kb, which is still somewhat large for a background image. But considering the resolution, it's excellent.

2) When I originally concepted this design, I picked and wrote down the rounded corner radius I wanted to use. Then, using Photoshop, I just made sure to set it to that value each time I created a new rounded rectangle. But, for the most part, each image was based off the same "template" that I conceived in the beginning.

3) Hmmm. Small tip. Box. You are too vague! Don't know what you mean.
Permalink Comment from Sensi on March 19th, 2008 at 9:16 AM
Ty Josh for this tutorial and piece of code. :)

I quickly needed some six images rounded corner box for a project and yours has done the trick perfectly. I have also given a try to Some.NET(Guy)'s one but it is in this state only for a four corners images box while i needed the two sides images because of some gradient border. Ty again.
Permalink Comment from Bjorn van der NeutEmail on April 2nd, 2008 at 2:26 AM
Great article,

the only thing I did wrong was if you make your first complete image and make it transparent. After doing ctrl+N, ctrl+A, ctrl+V the transparency is gone. So you have to set this up for every new image you create.

Thanks
Bjorn
Permalink Comment from vito on April 24th, 2008 at 1:04 PM
thanks very much your blog is very helpful
Permalink Comment from AYUSHEmail on April 27th, 2008 at 10:26 PM
Your BLog Is very Beautifull I LIke Your Transpprant effect But I dont lIke yoour Back ground Plz Change Your Back bround U Vista Nature Wallpaper
Permalink Comment from SpruceGuy on May 1st, 2008 at 7:12 PM
I have created a similar site to your blog and cannot get it to display correctly in firefox? it displays the top and bottom but no sides or content background it works perfectly in ie7 any thoughts?
Permalink Comment from Josh StodolaEmail on May 1st, 2008 at 9:46 PM
Actually, no. No thoughts at all. Sorry.
Permalink Comment from BlueBoden on May 11th, 2008 at 11:45 AM
Actualley i find that dealing with position based layouts is easier, the technique im using at the moment works in all "new" browsers, even IE7; Firefox; Opera; Safari.

http://www.brugbart.dk/bordertechnique.html
Permalink Comment from Mohit on May 16th, 2008 at 7:35 AM
I must say this is a beautiful post and nice background :)

okay
Bjorn,

i think you should play with opacity of the layer to get it transparent..

Thanks
Permalink Comment from ElenaEmail on May 16th, 2008 at 7:38 AM
Mohit,

i am looking the same blog as you sitting beside amer in office lol

well i too found this useful as our boss need round corners :)

cheers
Permalink Comment from seanEmail on May 17th, 2008 at 7:42 AM
nice examples i appreciate thanks
Permalink Comment from Brian on May 18th, 2008 at 12:35 PM
This is OK, but is this not possible without the use of so many DIV's. Any updated articles? I'm rather reluctant to creating more markup for presentational reasons.
Permalink Comment from Joe on May 21st, 2008 at 3:17 PM
Your website looks absolutely terrible in IE 6!

Don't you know at least 50% of the population of the world still uses IE 6!

browser compliance man, i know it sucks but it still needs to be done, This site reminds me of those sites back in 1996 that said "Best Viewed in Netscape" all over the page!
Permalink Comment from Josh StodolaEmail on May 21st, 2008 at 4:50 PM
Joe, I don't give a *crap* about anybody using IE6. If 50% of the population of the world still uses IE6, then 50% of the world had better get used to web sites looking terrible. The web is changing, IE6 is not, so to hell with anybody who still uses it.

Web sites should NOT be an exercise in "browser compliance", they should comply to the STANDARDS OF THE WEB. If you really think you can argue with that statement, then you are just too ignorant to discuss this with me. Go read some Zeldman and quit being stubborn and archaic.
Permalink Comment from Alex Boesel on June 2nd, 2008 at 4:23 PM
I just arrived here from a link on Matt Berseth's blog (http://mattberseth.com/blog/2008/03/tag_cloud_filters_with_aspnet.html), and I have to say that your site is one of the most interesting and visually appealing that I've seen.

Also, this is a great walkthrough! Being new to web development the attention to detail is highly appreciated. I just subscribed to your rss feed--looking forward to more!
Permalink Comment from Martin on June 6th, 2008 at 8:35 AM
Hi Josh,

btw funny message you're displaying for IE-people. I would usually agree with you, but your Website is scrolling very very slow in Firefox. IE-display is much faster. Now I'm wondering if it is so slow because of the PNG-transparency! Or should I get a new Laptop with Dual-Core?
Another thing is that I hardly can write this comment due to type-delays.
Permalink Comment from Josh StodolaEmail on June 6th, 2008 at 12:43 PM