Quick Tips

How to centre align your page or div

If you want to align your site in the center of the screen (horizontally), you just need to follow these two quick steps.

First, add this css code:

body {
	text-align: center;
}
 
#content {
	text-align: left;
	margin: 0 auto;
}

Then, create a <div> in your <body> with the id ‘content’, and put the actual content inside.

<div id="content">content</div>

Voila, your <div> and your whole page are centre alligned!

Post to Twitter Post to Digg Post to Facebook

Related posts:

  1. Reset your CSS
  2. Optimise your ‹title› and ‹description› meta tags

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped=""> in your comment.
CommentLuv Enabled

Trackback responses to this post

©2008-2009 Design Without Frontiers Magazine, all rights reserved. A project by IconOf.Com.