Centering a Web Page

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

What is the best way to center a web page on a site rather than have it
'left marginized'?

Thank you in advance.
 
1. Make the outermost table align center - <table align="center"....
2. Wrap the content in a center aligned div - <div align="center"....
3. Use CSS to control the width and margins on your content.

Take your pick.
 
Thanks for the tips Murray I'll try those....

Is there nothing I can put betwixt the <head> </head> tags that takes care
of the issue? - rather than delaing with body objects/elements?
 
Are you talking about CSS?

Here is using a wrapper to keep things in place..

Change the -

</head>

to this -

<style type="text/css">
<!--
body { text-align:center; color:#CCC; }
#wrapper { text-align:left; width:720px; margin:0 auto;position:relative; }
-->
</style>
</head>

change this -

<body ...>

to this -

<body ...>
<div id="wrapper">

and this -

</body>

to this -

</div><!-- /wrapper -->
</body>

That's about as easy as it gets....

bob
| Thanks for the tips Murray I'll try those....
|
| Is there nothing I can put betwixt the <head> </head> tags that takes care
| of the issue? - rather than delaing with body objects/elements?
|
| --
| _________________________
| Michael V Eayds MCSE
| What could possibly go wrong?
| _________________________
| | > 1. Make the outermost table align center - <table align="center"....
| > 2. Wrap the content in a center aligned div - <div align="center"....
| > 3. Use CSS to control the width and margins on your content.
| >
| > Take your pick.
| >
| > --
| > Murray
| > --------------
| > MVP FrontPage
| >
| >
| > | >> What is the best way to center a web page on a site rather than have it
| >> 'left marginized'?
| >>
| >> Thank you in advance.
| >>
| >> --
| >> _________________________
| >> Michael V Eayds MCSE
| >> What could possibly go wrong?
| >> _________________________
| >>
| >
| >
|
|
 
Is there nothing I can put betwixt the <head> </head> tags that takes care
of the issue? - rather than delaing with body objects/elements?

<head>
<div align="center">

....

</div>
</head>
 
Bob said:
<head>
<div align="center">

...

</div>
</head>

Sure, you can write CSS which applies to every <div>
<head>
<style type="text/css">
div {margin-left:10%;
margin-right:10%;}
<style>
</head>
or
div {text-align:center}
if that is the corect syntax.
(I usuallly check on w3schools, but for the last day or so, it is not
responding - I keep getting blank pages.)
 
Thanks for all your help - all of you's!

Here's what I ended up with from CSS

#headerdiv {
position: absolute;
margin-left: 10%;
margin-right: 10%;
z-index: 5;
width: 780;
height: 80;
background-image:url('pix/cbcsheader.jpg'); background-repeat:no-repeat;
background-attachment:fixed
}

That centered it for me....
 
Back
Top