How to Center Align Entire Site Using CSS

by on April 2, 2010

in Tips

For Webmasters cross browser compatibility is one of the major concern and if you are trying a fixed width layout and want your site as centered all you need to do is add the following to your CSS file.

body {
 text-align:center; /* for IE */
}

div#contentwrap {
 text-align:left; /* reset text alignment */
 width:748px; /* or a percentage, or whatever */
 margin:0 auto; /* for the rest */
}

Now make sure you add the following div just after the body tag.

<div id="contentwrap">

and end the div just before the closing body tag. Now your entire site will be center aligned in all browsers.

Enjoy !!!

Sign up for Free Course on Ways to Make Money Online?

Don't wanna sign up but prefer posts delivered to your Inbox?

But if you are not planning to subscribe through Email. Try subscribing to RSS.

Further Reading:

  1. Check Site Performance with Google Webmaster Tool
  2. Site Speed, Google & SEO. What have you done?
  3. Auto Withdrawal Option for PayPal In India

Leave a Comment

Spam protection by WP Captcha-Free

Previous post:

Next post: