CSS: Centering Your Layout

I see it everywhere, especially with newer website designers – uncentered layouts. Sometimes it works; most of the time it doesn’t. It seems very unprofessional to start.

In order to center your layout, put this code into your CSS:

margin: 0 auto;

Example:

#container {
width: 100%;
color: #000000;
background: #ffffff;
margin: 0 auto;
}

Now, the container div and anything inside it is now centered. (Ignore the other conditions such as width, color and background.)

Share

Statistical data collected by Statpress SEOlution (blogcraft).