written on:14 Mar, 2008 by Alen Grakalic
3 Simple Steps in Coding a Rounded Corners Layout
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed
![]()
What we should aim in coding is simplicity and try to avoid any unnecessary markup. Various rounded corners techniques often include several additional elements that are purely presentational.
When talking about fixed width, rounded corners layout, there's no need for complications.
Let me show you my approach to coding just that, fixed width, rounded corners layout in 3 simple steps.
As a special treat, PSD and XHTML/CSS files included in this brief tutorial :)
Take a look at the demo | Download zip file

Markup
Markup is pretty basic, and as you can see, there are no additional divs for top or bottom corners.
<div id="container"> <div id="header"></div> <div id="content"></div> <div id="footer"></div> </div>
Step 1 - Header
In order to simplify things I often crop entire header as a single background image. The size of the image rarely exceeds
50kb and it also makes additional changes a lot easier to apply.
With this particular layout we'll add something extra to the header cropping. We'll not
only crop entire header, but the top corners of the content area as well. That area is not
meant to have any content, it's just for presentation. It really doesn't matter if we put it at
the bottom of the header background image.

Note: if you use repeating gradient image for body background, like I do in my example, keep the height of the repeating image same or less than header height. That will make your life easier because you will not have adjust the body background in the content area.
Step 2 - Content
Unlike other sections, content area is expandable in height. Of course, we'll use 1px high gif that repeats vertically. We all know that :)

Step 3 - Footer
Similar as with header, we are avoiding additional markup for bottom corners of the content area. So, we'll "close" the content area with footer background image. So footer's background is used for end of the content and beginning of the footer.

That's it, view live example or download files (PSD included, yeah!)
About the author:
Designer, developer and a passionate standardista with large experience in all types of front-end work. Started to get involved with web in 1999. and turned freelance in 2005., the same year he started Css Globe. Alen's work has been featured on numerous css galleries including famous Css Zen Garden official list. Available for contract work.
Enjoyed the article?
Subscribe to our RSS feed or share it with your friends.
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed
Comments
Subscribe
Join 5000+ subscribers and receive our content instantly.
Follow us on Twitter
Want to be the first to know when a new article is published?
Sponsors

Sitegrinder 2 Photoshop Plugin

Look Professional with FreshBooks
Recent Articles
- CSS do's and dont's Part 2- Markup
- Easiest Tooltip and Image Preview Using jQuery
- 4 Uber Cool Css Techniques For Links
- CSS do's and dont's Part 1: CSS Selecting
- Easy Scroll: Accessible Content Scroller






kevin on 14 Mar, 2008 wrote:
Niall Doherty on 14 Mar, 2008 wrote:
panDyskoteka on 14 Mar, 2008 wrote:
cssglobe on 14 Mar, 2008 wrote:
panDyskoteka, as more people start to read Css Globe I realize that they are not all experts and I wanted to share something simple.
S. on 14 Mar, 2008 wrote:
Thanks!
Fubiz? on 14 Mar, 2008 wrote:
Optimas on 14 Mar, 2008 wrote:
regards
giannhse on 15 Mar, 2008 wrote:
Alex -Tucson Web Design on 17 Mar, 2008 wrote:
Thanks!
Dallas Web Designer on 17 Mar, 2008 wrote:
Armen on 18 Mar, 2008 wrote:
Stumbled!
John Faulds on 19 Mar, 2008 wrote:
Sunlust on 19 Mar, 2008 wrote:
Thanks a lot for this post and for downloable version.
Sunlust
Lee on 21 Mar, 2008 wrote:
Josh Miller on 23 Mar, 2008 wrote:
cssglobe on 23 Mar, 2008 wrote:
As for the footer you can easily make it variable in height if you use additional elements. I often use a paragraph with copyright info for the "bottom" element.
jive on 24 Mar, 2008 wrote:
<h1 id="headerimage">Rounded Corner header</h1>
<p id="contentbackground">Rounded Corner Content</p>
<div id="rooterimage">Rounded Corner Footer</div>
Less markup and a bit more semantically correct.
Frank Rosendahl on 27 Mar, 2008 wrote:
Read more: http://www.quirksmode.org/css/condcom.html
http://msdn2.microsoft.com/en-us/library/ms537512.aspx
Frank Rosendahl on 28 Mar, 2008 wrote:
Jad Graphics on 2 Apr, 2008 wrote:
ididthis on 3 Apr, 2008 wrote:
cssglobe on 3 Apr, 2008 wrote:
css IS easy :)
Quoka on 4 Apr, 2008 wrote:
In this age of "do it with Javascript" , many people seem to forget the simple options
James Abney-Hastings on 5 Apr, 2008 wrote:
Beth on 8 Apr, 2008 wrote:
it is indeed very easy to get lost up your own nether regions when bumping over from static, image/table based layouts to a more flexible css route. as i've found recently.
all these statements, whether you're new to this industry or not, make absolute sense.
good man. have a banana.
krishnamoorthy manickam on 8 May, 2008 wrote:
Roman on 20 May, 2008 wrote:
When developing kogelberg.at I was using this as a source
http://www.alistapart.com/articles/customcorners2/
4 singel images that define the background of your box, and, given enough height/width, the images scale with the size of your browser fontsize. I think it's far more advanced, although not so easy to maintain, if you want to exchange the background images.
To get an idea, tak a look at
kogelberg.at
But I really appreciate the design of your website - currently about to explore :-)
Regards, Roman
Rsk on 27 May, 2008 wrote:
Matt Mikulla on 4 Jun, 2008 wrote:
"3 Simple Steps in Coding a Rounded Corners Layout"
It really reinforces the truth that we can make things simple. Sure, you could slice up the layout into more images and allow for flexibility, but as you mentioned, you would need to edit all of those slices if your layout needed alteration. I would rather edit 3 than many more and then have to hassle with more html and css markup.
Violetta Grawson on 14 Jun, 2008 wrote:
Thanks!
Ed Thomson on 14 Jun, 2008 wrote:
sophy on 16 Jun, 2008 wrote:
Kevin on 16 Jun, 2008 wrote:
Richard Vanbergen on 7 Jul, 2008 wrote:
<div>
<img src="example.jpg" class="leftBorder"></div>
<div class="headerBG"><h1>heading</h1><p>Tagline</p>
<img src="example.jpg" class="rightBorder"></div>
</div>
For the header, a 1x250 image (repeat-x) will load a lot faster then a 800x250 images.
There is a reason we like to make things difficult for ourself. ^^
Richard Vanbergen on 7 Jul, 2008 wrote:
Sean OBeara on 17 Jul, 2008 wrote: