How To Center A Website

Here’s a quick and dirty way to center a website.

It’s simple really. You just need to provide two basic properties in your CSS to include in order to center the content on your website.

Here’s an example of an HTML structure:
[HTML]
<html>
<head>
</head>

<body>

<div id=”Wrap”></div>

</body>
</html>

[/HTML]

And here’s the actual CSS snippet to center the #Wrap div.

[CSS]
#Wrap {
width: 800px;
margin: 0 auto;
}
[/CSS]

As you can see, you only really need two properties: width and margin. Notice, however, that when using margin: 0 auto; you need to provide a definitive width size.

That’s really all there is to it.

Leave a Reply

Your email address will not be published. Required fields are marked *