1. Home
  2. Website Design
  3. Portfolio
  4. eCommerce
  5. Web Optimisation
  6. Website Video
  7. Graphic Design
  8. Blog
  9. Team
  10. Contact

Print This Page
Print this page.

Website Design: Centering Web Page

Posted by on Wednesday, February 24th, 2010 at 11:51 pm.

It is always useful in the website design industry, to go back to basics and brush up on the some of more simpler of understandings. Today I will be look into the methods and techniques for centering websites, including the most common method and possible issues you may have come across, whilst checking your website for cross browser compatibility.

Website Design Basics Centering a Web Page

Firstly we’ll take a look at the CSS, and in particular the settings for the margin of our div. When a margin is declared, if you state only one margin value, then that value will be applied to all four sides of the div. If you declare two values, the first value will represent the top and the bottom sides, whilst the second represents the left and the right.

The following statement will render our div to have equal and automatic margins either side. Now secondly, for this to center the page, we must specify a fixed width, which in turn will centre our container

#container {Margin:0 auto; width:900px}

and the html…

The above piece of HTML and CSS will simply centre the div #container and give it a fixed width of 900px, keeping the centre alignment at all times, regardless of browser windows size. If only all website design was so easy!

Possible Internet Explorer Issues

Sometimes the “margin:0 auto” will not work when using the Internet Explorer, even though all versions of IE from 5.5 onwards do support it. The common telltale sign of this, is that the div will retain its width, but sit to the left. This could be down to several reasons, but you could try using a supported Doc Type or put text-align:centre; on your body tag.

Related Posts

Leave your Comment

Bookmark and Share Creare

Twitter
twitter.com/crearegroup

Recent Blog Comments

  1. Ypho: Never seen this....
  2. Craig Riches: Disregard my las...
  3. James Bavington: Hi Craig, thank ...
  4. Craig Riches: Ahh yes, "Live V...
  5. Simon: All these tutori...

Latest Web Design Blog

Testing Websites with Adobe BrowserLab
Posted on Fri, 30 Jul 2010

In this week's web design video blog, Nick and James explore Adobe's new Browserlab service. Browserlab allows web designers and developers to easily test how their website renders on all the major Internet Browsers.