Skip Navigation

Centre the <body>

Tags: FrontPage
File Author Send email Website
2009100602 Ronx to Ronx www.rxs-enterprises.org

Centering Shared Borders: CSS and <body>

How to centre a page using CSS by restricting the width of the page <body>


It is possible to center a page that uses FrontPage Shared Borders. CSS is required to set the width of the page (including the borders).

Open the website and page in FrontPage.

Switch to Split View (FrontPage 2003), Code View (FrontPage 2003 or 2002), or HTML View (other versions).

At the top of the code add a complete and valid !Doctype. This is required to ensure all the CSS works in all browsers. The !doctype takes the browser out of Quirks mode, and places it in Standards mode. An example of the !doctype is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

This MUST be added at the very top of the page, before the <HTML> tag.

Scroll down to the </html> tag.

Add the following:

<style type="text/css">
body {width: 760px; margin: 0 auto;}
</style>

The page will now be centred with a fixed width of 760px.  Change this value for wider pages.

The above CSS can be placed in an external style sheet, along with any other CSS rules.

See this example page to see the effect.