Centering a Web Page


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.
 
Ad

Advertisements

M

Murray

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.
 
M

Michael

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?
 
B

Bob

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?
| >> _________________________
| >>
| >
| >
|
|
 
M

Michael

Got it! I used your #3 as in:

margin-left: 10%;
margin-right: 10%

Thank you.
 
M

Murray

Hmm - not exactly what I had in mind, but that works.... Sorta. 8)
 
Ad

Advertisements

B

Bob

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>
 
T

Trevor L.

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.)
 
Ad

Advertisements

M

Michael

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....
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Centering web pages 2
centering web page 3
Centering the whole web page 15
web page in center of browser 7
Centering Web Page on Server 2
How to center a web page? 1
centering my web page 1
Page Centering 0

Top