Need a new website this autumn?

Project Planner

How to centre a DIV using CSS

3rd August, 2010

In our Tidy Blog we will show you how to use CSS to control the style and layout of multiple web pages! For example, if you wanted your content DIV to have a width of 700 pixels and to be centred in the browser your CSS would read:

#content {
  width: 700px;
  margin-left: auto;
  margin-right: auto;
}

The above  code works in IE 6, 7, 8, Firefox, Opera and Safari so all you now need to do is insert:

<div id=”content”>test</div>

in the body of your webpage and away you go!

Web Design Posts

Recent Posts

17th September, 2024

Pompey Poems Book

12th September, 2024

Pause and Reflect

23rd July, 2024

Gen 4 VPS Migration