The code below can be used to center your webpage in a browser window. The code will need to be pasted after the <head> tag but before the </head> tag.

<style type="text/css">
.wrapper{
position: relative;
width: 740px;
margin-right: auto;
margin-left: auto;
}
</style>

 

Make sure to enter the actual page width into the width statement above.

To use this code, you have to enclose the whole page into a <div>. Here's how: First, place this code directly after the opening <head> tag:

<div class="wrapper">

Next, place the following code tag directly above the closing </body> tag:

</div>

This procedure will place your entire HTML page into a centered floating wrapper. You do not have to call it "wrapper"; give it a different name if you wish, as long as the style declaration matches your style ID.

If you are going to perform this process on multiple pages, check out the article on External CSS files.