Rounded corners are one of the most sought-after graphical elements on the web. Hence we have a myriad of implementation with more or less bloated code. The reason is that you need four hooks to attach the four images needed for flexible boxes. With typical box markup of header plus paragraphs/lists, it can be hard to find appropriate elements, especially with outdated and buggy browser implementations.
Once you do away with browser constraints and develop for the best in the field, all the markup is 100% semantic.
1 2 3 4 5 6 7 8 9
div defines the box,
h2 defines the header,
p defines content and
a defines fast-access URL point. Semantic, flexible and good looking. What else to ask for? Apart from browser support, nothing.
CSS is little more than just basics. The background of the whole box is bottom-right corner:
1 2 3 4 5
Header is the top-left hook. Pay attention that all the following properties are needed. Margin is removed, padding needs to leave some space for the curves and glow. Position is needed so we can precisely position the top-right image while overflow and line-height are there to (hopefully) avoid possible browser surprises.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Then comes the top-right corner, for which the anchor is used, with rules that make it fit nicely.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Bottom-left corner is applied to the last element in the box, in my case last paragraph:
1 2 3 4 5 6 7
But one thing is missing - the right edge is not “closed”. To avoid the need for one more image, I use the bottom-left corner image again, but this time aligned to the top-left - this works great as long as you make sure that this image is at least 2x higher then largest assumed paragraph width.
1 2 3 4 5 6 7 8 9
And there it is. Nice and simple. Before the end, here are the four images used to make this example work.