Home Tutorials Fonts Lists Freelance Web Designers List Feed RSSContact Me

Sunday, October 7, 2007

Design page layout using CSS

Save to delicious 0 hits

Today's lesson will explains how to design page's layout for your site using a css file. In the previous lesson we have seen a typical website structure which we can use to project our site. In the css folder create a new css file called default.css where insert the css code to design the page's elements.

Now, open index.php and put this code into <head> tag:

<link href="css/default.css" rel="stylesheet" type="text/css" />




In this way index.php will get all informations about the page's design from the CSS file default.css

Page layout and CSS code
Before you proceed, it's useful to have an idea about page's sections. I suggest to use this layout (2 column fixed size):




Copy and paste this code into default.css file:

/* ------------------------------
PAGE STRUCTURE
------------------------------ */

/*
#container has an absolute width (780 pixel)
The width of inner elements is set to auto,
in this way all inner elements have the same
width of the element which contains them
*/

#container{width:780px; margin:0 auto;}
#topbar{width:auto; display:block; height:80px;}
#navbar{width:auto; display:block; height:24px;}

#main{width:auto; display:block;}
#column_left{width:560px; margin-right:20px; float:left;}
#column_right{width:200px; float:left;}

/*
div.spacer, solve an issue with #container height
in css 2 column layout.
*/

div.spacer{clear:both; height:10px; display:block;}

#footer{width:auto; display:block; height:24px;}


The basic page structure is ready! In the next lesson we will format index.php file, adding layer using default.css file.

Related Posts
Optimize CSS files to improve code readability

Sponsored Links
Share this post
Share on Facebook
Share on Twitter
Share on StumbleUpon
Share on Delicious
Share on Reddit
Share on Digg
Share on DesignFloat
Share on Technorati
Feeds RSS Subscribe to Feeds RSS
Old Comments
Kano said...

Good work and nice design for this blog!

Antonio said...

Thanks for your comment :)

Emma said...

Ola Antonio, very usefull post!

Ying Xiong said...

This helps me a lot! Thank you!

Anonymous said...

Thanks for the help in showing others what you know. Much appreciated

Anonymous said...

this is best updated css from the web, I learn a lot from the example, thanks for the sharing such knowledge with us !!!.

Yi Mao

geeth said...

thanks for sharing.. very helpful.. keep posting

lil.D said...

Thanks a lot, So nice tutorial

Chris Hale said...

#column_right{width:200px; float:left;}

should be

#column_right{width:200px; float:right;}

Anonymous said...

Love the pencil drawing layout and labeling! Thanks and many blessings!

mahender said...

This kind of exampls every one can learn css and html

Anonymous said...

I don't get it.. CSS file? Where? How?

szita said...

Thanx. Love this blog!

pong- said...

That very good of tutorial! Thank you.

wantedwahab said...

I like your sketch style

where is the next lesson ?

About Me

I am Antonio Lupetti, Engineer, Pro Blogger, Mac user, Web addicted. Rome, IT.
Feeds RSS Contact Me

SubscribeFeeds RSS

Contact Me Enter your email address:

SubscribeLatest posts

SubscribeHot Links

Subscribe Design News

Apple Reviews and News
CSSRockstars - You Design, We Code. Your PSD to HTML/CSS for just $149