Using CSS To Centre Content

Cleaner Code

If you've used tables in your html page design and moved to CSS, the shift away from tables and using CSS is a little different.

If you want to centre a page in CSS. First create centred liquid layouts:

body { text-align: center; }

#content {
margin-left: auto;
margin-right: auto;
width: 500px;
text-align: left;
}

First we center the body, then we set the left and right margins to auto so they adjust to the width of the browser. This creates text that's centred. To correct that we set the text to left align.

. . .