Sunday, July 19, 2009

How to center your web page content using a div

Go to google.com and try resizing the page. Notice how everything remains centered? Well the trick to using that is by using <div>'s. The way you do this is the following:

1. Insert the following code into a CSS file:
body
{
text-align: center;
}

div.content
{
text-align: left;
}

2. On your content page insert a <div class="content">

Voila! Your div will now be centered and all it's content will be left aligned :)

No comments:

Post a Comment

There was an error in this gadget