How to code Six Revisions’ layout better than Six Revisions
Last week, I taught you how to slice Six Revisions’ layout in 12 easy steps. Today I’ll show you how to code their layout better than them!
There are many blogs out there that I really like: Smashing Magazine, Freelance Switch, Think Vitamin, Designm.ag, Nettuts, etc. Six Revision is one of them. Unfortunately, sometimes their articles is not as good as they should be. (Not only for Six Revisions.)
I mean, they have the money, they have the fame… but they should give me money and fame and concentrate on writing content of the highest quality. Hence I decided to write a “better than” series to show how to take some of their articles from good to great. That’s my way to pay tribute to these blogs I love.
Before you begin
You can read how to design Six Revisions’ layout, and how to slice it. Or simply download the sliced pics we need in order to do this tutorial.
You can also read the article we are going make better: Minimal and Modern Layout: PSD to XHTML/CSS Conversion or already check the final result.
What is “better” for me?
It’s not about how the tutorial is well-written, or full of good-looking pictures. It’s about code quality, standard compliance, best practices, work-flow, and tricks you should use to work more efficiently.
Download My Simple Framework:
In order to work quicker and better, download My Simple Framework and unzip it. (If you want, take one or two minutes to get familiar with it.)
It should look like this inside:
Today we will code in XHTML, so open the XHTML folder. Here is what you should see:
Why is it better?
It is better than Six Revisions’ tutorial for many reasons. In short, My Simple Framework (MSF), will take care of many issues that Six Revisions’ tutorial forgot or neglected. (Other frameworks such as 960.gs, Blueprint, etc. are good too.)
For example, MSF provides a powerful build in CSS reset and many useful default values, but Six Revisions use an old and “not so good” CSS reset:
margin: 0px;
padding: 0px;
border: none;
}
Another example: Six Revisions wrote NOTHING about typography. But typography, it’s rhythm, it’s flow, the font choice, etc. are an important part of any design and should be taken in account when building a layout. MSF features a beautiful typography, with many size and baseline grids.
More: MSF provides a xml:lang attribute, an IE special stylesheet, a print stylesheet, etc. Six Revisions’ tutorial lacks all these.
Creating the layout
1. First let’s take a look at what we want to create. Here is the structure of our web template:
You don’t need to code anything yet. A mere copy-paste will be enough to create a good basic layout. But (sadly) whereas the usual width for layouts is 960px, this one is 850px large… (what for? I wonder…)
2. Open “css/layout/960px fixed layouts/” and copy head-nav-2col(1-2)-2col(2)-960px.css
3. Go back to the “css” folder and replace layout.css with this file (delete layout.css, paste head-nav-2col(1-2)-2col(2)-960px.css, rename it layout.css):
4. You can already take a look at your website and open index.php with your favorite web browser (I’m sure it’s Firefox!). Here is what you should have:
Not bad for a mere copy-paste, right? Now, we simply need to merge the header and the navigation section, and to give their width to our layout elements.
5. Open up index.php in your favorite code editor; I’ll be using Notepad++ for this tutorial (for bigger projects, I like Aptana Studio). Find the following code:
<div class="inside">
<!-- add your content here -->Nav
</div>
</div>
<div id="header">
<div class="inside">
<!-- add your content here -->Header
</div>
</div>
<div id="nav">
<div class="inside">
<!-- add your content here -->Nav
</div>
</div>
Delete the navigation sections so that only the header remains:
<div class="inside">
<!-- add your content here -->Header
</div>
</div>
6. Now, open layout.css. In order to give the proper width to all your layouts elements (columns, header, wrappers, etc.), you can use the search and replace function (ctrl+f):
- search for: 960px, replace with 890px;
- search for: 240px, replace with 300px;
- search for: 720px, replace with 620px;
Here is the result:
Why is it better?
First of all, this layout can be done in seconds if you know what you want to do. I mean 1 copy-paste, delete 2 sections of text, and do 3 search and replace can be done in less than 50 seconds.
Then, a big flow of Six Revisions markup is that the content appears AFTER the sidebar. It’s not (really) good for SEO and accessibility. With my method, your content (level-2 > column-5) appears before the sidebar (level-2 > column-6).
One more crucial thing: It’s an organized workflow! You can’t slice a part, code some CSS, slice another thing again, write some XHTML, slice again, code again, and so on. That’s just wrong! If you don’t want to fail like an amateur, please use some kind of plan, for instance: Design / Slice / Layout (XHTML) / Layout (CSS) / Content (XHTML) / Content (CSS) / Features (jQuery) / etc.
(I only stress the important things because it would be too long if I wanted to write everything that is better).
Adding the background
7. Make sure that you have all the required sliced files. (You can also download the whole “layout” folder again).
Put all these pictures in “images/layout/” like this:
8. In layout.css, delete the default backgrounds:
body { background: #d5e8f3 url(../images/layout/body-bg.png) repeat-x top; }
#header, #top-nav, #nav, #level-1, #level-2, #footer { background: #fff; }
.inside { background: #f1f1f1; }
9. Then starting with the body. We are going to add all the backgrounds (please note that when required, we will add the proper height/margin/padding too):
background: #001b32 url(../images/layout/top-bg.png) repeat-x top;
min-width: 890px; /* Prevent the liquid layouts from breaking */
}
/* Section for additional styling purpose */
#main-wrapper {
background: url(../images/layout/main-highlight-bg.jpg) no-repeat center 120px;
}
10. For the column-2, we must add a 370px height to protect the background:
background: url(../images/layout/right-pics.png) no-repeat -2px top;
height: 370px;
float: left;
width: 49.99%;
}
11. Here, the 60px padding-top provides enough space to display the horizontal bar:
background: url(../images/layout/middle-hr.png) no-repeat center top;
margin: 0 auto;
padding: 60px 0 0 275px;
width: 560px;
}
12. For the sidebar, we are going to layer to background images in order to use the sliding-door technique. Hence, we need to delete the margin of the inside div. Moreover our slice is not pixel-perfect so we are going to “move” our background a bit:
background: url(../images/layout/sidebar-box-top.png) no-repeat 4px top;
float: left;
width: 275px;
margin-left: -100%;
left: 275px;
}
/* Protect the layout from IE strange behavior */
#level-2>#column-6 {
left: -275px;
}
#column-6>.inside {
background: url(../images/layout/sidebar-box-bottom.png) no-repeat 4px bottom;
margin: 0;
padding: 0 60px 40px 23px;
}
Why is it better?
With this method, the sidebar height can increase without breaking the layout. If you used Six Revisions’ layout and put too much content, very bad things would happen:
![]()
Oh! And I forgot another (small) better thing. A width of 890 pixels is better than 850 pixels for this layout because that allows consistent margins around the content. (And consistent things are sweet).
Adding Content
Up to now, our website is only an ugly creature with no meaning. It’s time to turn it in a talkative little princess: let’s add the content.
13. When you add the content, you should always keep in mind how you are going to style it later in your CSS file(s). You should also be careful and use the proper XHTML tags for each element you write.
14. That being said, we can edit our index.php file again. First we are going to add the site title and the navigation menu. Find the header section and write this:
<div class="inside">
<h1><a href="#">Your</a><a href="#">Website</a></h1>
<h3><a href="#">Your Jazzy Slogan Here</a></h3>
<ul>
<li id="home"><a href="#">Home</a></li>
<li id="about"><a href="#">About</a></li>
<li id="portfolio"><a href="#">Portfolio</a></li>
<li id="contact"><a href="#">Contact</a></li>
</ul>
</div>
</div>
And in layout, change #header>.inside to:
margin: 0 10px;
padding: 0 10px;
}
Why is it better?
Because we don’t use any image for the logo (I can’t see any good reason to use an image for a text with no gradient…). And we’ll be able to style the logo through CSS only later, with a small trick :)
Our solution is better too, that’s only a detail, because we didn’t specify a class for the unordered list. (You can target this list with CSS only, there is no need to add a class here. Moreover a “ID” would be more suited in this situation).
Last thing, adding a class to the last list item is just wrong. Please use the CSS selectors… don’t add unsightly crap to the markup!
15. Now add the content and the sidebar markup:
<div class="inside">
<h2>welcome to <span class="h-color2">yourwebsite!</span></h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque lacinia pellentesque neque in hendrerit. Suspendisse in malesuada mi. Donec in dictum neque. Mauris vel lacus eget risus fermentum tristique. Nulla ac elit augue.</p>
<p>Proin fringilla nunc lorem, in sollicitudin orci. Sed ut eros ligula.</p>
<ul>
<li>Lorem ipsum dolor sit amet...</li>
<li>Lorem ipsum dolor sit amet...</li>
<li>Lorem ipsum dolor sit amet...</li>
<li>Lorem ipsum dolor sit amet...</li>
</ul>
</div>
</div>
And:
<div class="inside">
<h2>welcome to <span class="h-color2">yourwebsite!<span></h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque.</p>
</div>
</div><!-- end div #column-5 -->
<div id="column-6">
<div class="inside">
<h3>lorem ipsum dolor</h3>
<ul>
<li>Lorem ipsum dolor sit amet, consectetur sit adipiscding...</li>
<li>Lorem ipsum dolor sit amet, consectetur sit adipiscding...</li>
<li>Lorem ipsum dolor sit amet, consectetur sit adipiscding...</li>
</ul>
</div>
</div><!-- end div #column-6 -->
16. We can finish with the footer (I’m leaving Six Revisions’ copyright without adding mine because I’m a nice fellow):
<div class="inside">
<small>Copyright © Six Revisions - Design By Richard Carpenter</small>
</div>
</div><!-- end div #footer -->
Why is it better?
Well… again we are using a little less markup (and, if you read the recommendations of W3C, that’s definitely a habit you have to take as soon as possible).
However, I must admit that generic column names such as “column-5″ are less semantic than “sidebar” and “content”. (But, sometimes you can’t make everything perfect.)
One other benefit of building your website like I’m showing you is that you (somehow) follow the rules of progressive enhancement. It means that you add layers of technology one by one and make sure that everything is as accessible as possible.
Here is what you should have:
Styling content
Time to have FUN! I love styling everything with CSS and I’m sure you’ll love it too :)
17. Open typography.css with your code editor. First, we need to choose a decent sans-serif font stack for the headlines. Find and change the following code in the CSS file:
font-style: normal;
font-family: Tahoma, Trebuchet, Geneva, Verdana, Helvetica, Arial, sans-serif;
margin:0;
padding:0;
}
18. Now we want to display our logo in two colors, make it change on hover, and give it a fixed size to protect the layout from browser resizing. Add the following code, right after the previous bunch of code:
color: #8d8d8d;
text-transform: none;
font-size: 25px;
float: left;
margin: 0 20px 0 0;
line-height: 120px;
}
#header h1 a , #header h3 a{
color: #8d8d8d;
text-decoration: none;
}
#header h1 a:first-child {
color: #004987;
text-decoration: none;
}
#header h1:hover a, #header h3 a:hover {
color: #6e6e6e;
}
#header h1:hover a:first-child {
color: #00284a;
}
#header h3 {
float: left;
color: #989898;
font-size: 12px;
line-height: 120px;
margin: 0;
}
This code features two neat tricks. The first one is to use line-height to vertically center some text (I like this trick). The second one is to put the “hover” property on the h1 tag, and NOT on the link itself. That way, you can create a bicolor link which react as a normal link!
19. Last thing to finish the header is to style the navigation. It’s often a mess (IE just won’t do what I ask him to).
Here is the CSS code:
list-style: none;
float: right;
margin: 0;
width: 485px;
}
#header li {
float: left;
width: 120px;
height: 119px;
border-right: 1px solid #cecece;
text-align: center;
line-height: 119px;
}
#header li:first-child {
border-left: 1px solid #cecece;
}
#header li:hover {
background: url(../images/layout/top-nav-focus.png) no-repeat center bottom;
}
#header li a {
padding: 0;
text-decoration: none;
text-transform: capitalize;
color: #666666;
}
#header li a:hover {
color: #00284a;
/* text-shadow: 0 0 3px #B7B7B7; */
}
Why is it better?
List elements are floated instead of the anchors tags (<a>). The whole code is way cleaner and uses up to date CSS properties. The text-shadow property adds a little softness to the links (uncomment it and see if you like).
20. Now that our header is appealing, we can concentrate on the content.
Change the body text color:
color:#C8C8C8;
font: 13px/1.615385 Verdana, Helvetica, Arial, sans-serif; /* Remove pixel size to enable font-size changed by browser */
}
Then find:
font-size: 1.8461543em;
line-height: 0.875;
margin-top: 1.75em;
margin-bottom: 0.875em;
}
Change to:
color: #ffffff;
font-size: 1.307692em;
line-height: 1.235294;
margin:1.235294em 0;
text-transform: uppercase;
}
h2 span.h2-color {
color: #9a9a9a;
}
#column-5 h2 {
margin-top: 0;
}
21. The lists are a total mess in Six Revisions’ tutorial, and I would be ashamed – as a web designer – if I dared to use something like that on a paid project. So, we are going to do better. Find the “Navigation & Lists” section and add the following code:
list-style-type: none;
}
#column-1 li {
background: url(../images/layout/list-unordered.png) no-repeat -1px 5px;
float: left;
width: 172px;
padding: 0 5px 0 18px;
}
Why is it better?
The list background-image stays on the first line of the list, as it should. Moreover there is enough padding.
If you used Six Revisions’ layout and put too much content, very bad things would happen (again):
22. We are almost done! Stay strong :)
We can now style the sidebar. Add the following code:
font-size: 12px;
line-height: 19px;
text-transform: uppercase;
color: #ffffff;
text-align: center;
}
#column-6 ul {
margin-top: 14px;
}
#column-6 li {
font-size: 12px;
line-height: 18px;
list-style-type: none;
padding-top: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #00172C;
border-top: 1px solid #002342;
}
#column-6 li:first-child{
border-top: none;
}
#column-6 li:last-child{
border-bottom: none;
}
Why is it better?
It’s always good to avoid using pictures when you can. One less picture is one less request to the server, and it’s easier to change pure CSS styles than redesign pictures with Photoshop. (And even if we used a :last-child selector, old browser will still display the list nicely.)
23. The footer is easy to style if we switch to the layout.css file. Find the footer styling and change it to:
background: url(../images/layout/footer-bg.png) no-repeat center;
margin: 0 auto 20px auto;
width: 890px;
}
#footer>.inside {
text-align: center;
}
24. Last, yes last of the last, make sure everything is perfect. Delete the remaining default text (“Level-1 > Column-2″), write the meta tags, etc.
Here is the final result. Enjoy!
If you want you can download the files here.
What now?
I hope you learnt many new things about workflow, clean markup, standard compliance and best practices in general.
When we read professional web designers’ articles and tutorials, we may find ourselves very small and unskilled. But they do mistakes too ^__^ (hopefully I’m not a pro yet). So, be confident!
Writing this tutorial took me 8 long hours (I mean the code took me 45min, but writing the tutorial itself was way harder… I wish English were my native tongue, really!). But I had fun.
Next time, I’ll write an article “better than” Smashing Magazine. So, be sure to grab the RSS and don’t miss it!
What do you think of this tutorial? Is it useful to you or do you think it is a waste of time? Any idea to make it better?
Please tell me!!!
Thank you.
Related Posts
You may want to check out the following related posts:
Dan
November 9th
Hello
I’m not sure if it’s better. For the person who would like to learn how to code it is very bad practice to copy and edit somebody’s code. And why are you using .php file for this simple website?
Like or Dislike:
0
0
Tsedaka
November 10th
@Dan
Hi! This article is not for beginners, and as I already said… all that matters is the work-flow and the quality of the code.
Why Am I using php? Because sooner or later, when you make a website, you’ll have to add php. Sure, right now it’s only a simple website and php isn’t useful at all, but you need to plan for the future.
Last thing: for people with some web design knowledge, it is a very good practice to use Frameworks, and edit somebody else’s code. I believe that I learned more studying other people code, and every framework out there, than reading articles for beginners.
At one moment, you have to decide to go one step further. Stop writing code like a beginner and aim for a higher level.
Like or Dislike:
0
0
Roland
November 10th
Hey again :) Well, for me it is totally better than Six Revisions, but there is always a possibilities to improve something and do it better, so I’m definite, that there is some designer, that can say you have so many mistakes in your design and will offer a better. That’s every person’s individual choise :) Anyway, I liked both articles, yours and the one from Six Revisions. Their article is maybe more for beginners. Their article is as I love to say – food for your brains. You read, you find some mistakes, you think how to do it better. Your article is more like a finished one with all mistakes already improved. But it is for advanced designers. Lots of newbies won’t understand, what and how you did :) However, it is very simple to understand your language.
As for me, I found a lot of useful tips and trics how to avoid stupid mistakes. And I totally disagree with the first person, who wrote a comment here. I think it is one of the best ways to teach showing how almost the same things can be done in very different ways.
Ok, I already wrote an essay here, so I’m going to finish my comment :D Keep posting cool articles, tutorials, web tips and so on ;)
Take care,
Roland
Like or Dislike:
0
0
ThunderWolf
November 10th
Well done, good css understanding.
Thanks for the tut.
Cheers!
Like or Dislike:
0
0
Tsedaka
November 10th
Woaw! Roland, you are such a nice guy!
I would keep the blog running for you alone if I had to :)
Btw, I found and started to follow you on Twitter.
Like or Dislike:
0
0
Roland
November 10th
Thanks :D
And even more Thanks for following :) I’m now following you back also. That is strange, that I didn’t do that before, cause I always do that when I found somebody, whose blog or posts of messages are interesting for me :) Maybe I was just very busy lately. Anyway, as you are following me on twitter now I hope my messages will be also interesting for you :)
Cheers!
Like or Dislike:
0
0
Jaime
November 10th
“sooner or later, when you make a website, you’ll have to add php” Woa what? Since when? There are a myriad of other options and beginners will probably start with only markup and css anyway. As a matter of fact. I create all my webdevelopment first as stand alone static websites with mockup content and then integrate from there. I believe this is a better option.
Anyways, I found the tutorial very useful, but I don’t agree this is a beginners tutorial; nor do I agree that beginners should not be “editing” other persons code. On the contrary, beginners should probably copy all they can in the beginning. They can learn best practices, nifty tricks and tips, and overall how to work with projects. I’ve taught more than my fair share of people and believe me, giving a newbie freedom is a recipe for disaster and disappointment.
Like or Dislike:
1
0
Design Informer
November 10th
Good tutorial. Especially good for those who want something than just a basic tutorial.
The only thing I have against it is the title of the post. Why not rename it into something instead of saying it is better than Six Revisions?
Also, why not design your own design and code it instead of using Six Revisions? Just my two cents. :)
Anyways, nice site you got here. Just added it to my favorites.
Like or Dislike:
0
0
Tsedaka
November 10th
@Jaime
I never said that this is a tutorial for beginners… I said:
“This article is not for beginners” LOL
So we say the same ^^
@Design Informer
Thank you.
Next one will be only my own design code but I was disappointed with Six Revision’s tutorial… and wanted to make it better :)
Like or Dislike:
0
0
gavin
November 17th
I really like the article and no its not aimed at begginers and its not aimed at season code writers, it seems to be aimed at me?! :-)
I currently take about a day to slice and code a design into xhtml, and I mean a full day.lol
You have opened my eyes up to frameworks, and for now, I think I will use yours, but I will definitely check out the others that you refer to.
One thing I would say though…. using the statement “”Why is it better” over and over again did not lend its self well to the article. I totally get were you are coming from, but I think once you stated why, you could have used something else for the rest of the article. I am not quite sure what, maybe “How this helps…” I think the main aim of the article is to teach us how to use a framework to get a solid result, and a little bit of ‘this is better than the one I just read’. So I dint need to keep reading how yours is better than so and so’s
But that is a minor thing, and I really enjoyed the post.
Thanks
Like or Dislike:
0
0
Tsedaka
November 17th
Thank you!
For the next one I’ll try to follow your advice. And if you have any comment/advice to make my framework better, you are welcome ^^
Like or Dislike:
0
0
LaDonna
November 23rd
I learned alot about using framework from your article. Thanks for revising Six Revisions.
Like or Dislike:
0
0