Horizontally centre a website
March 20, 2011We use a fixed width when creating websites although this is not the only way to create a website we find that it allows us to keep complete control over the layout. When using a fixed width we find the best way to centre a website is to put it inside of a container and then apply styles using CSS.
To make sure the site is as accessible as possible we use a width of around 1000px so that it can easily be viewed on almost any monitor available today. The HTML and CSS mark up to centre a website is:
HTML
<div class="container"> <!-- Content Here --> </div>
CSS
.container {
width: 1000px;
margin: 0 auto;
text-align: center;
}
It’s as simple as that!
This entry was posted in Tutorials. Bookmark the permalink.




