how to make web site align in the middle

J

Jonathan N. Little

ARC said:
can you please tell me how to make the entire web site and pages align
in the middle?
For example:
http://www.travelzoo.com/
http://www.yahoo.com/

Any simple html commmands I can use?

Simple CSS properties... put page elements in a containing "wrapper"
div. And set CSS properties for 'wrapper" width to something specific
and margins left and right to auto


examples:

div.wrapper { width: 80%; margin-left: auto; margin-right: auto; }

div.wrapper { width: 35em; margin-left: auto; margin-right: auto; }
 
N

Neredbojias

Simple CSS properties... put page elements in a containing "wrapper"
div. And set CSS properties for 'wrapper" width to something specific
and margins left and right to auto


examples:

div.wrapper { width: 80%; margin-left: auto; margin-right: auto; }

div.wrapper { width: 35em; margin-left: auto; margin-right: auto; }

Also for wrapper interior contents set text-align:center;
 
J

Jonathan N. Little

Neredbojias said:
Also for wrapper interior contents set text-align:center;


Only if you want the text centered as well. As per examples OP gave this
did not seem to be desired.... but was common with the ol' GeoCities
Scroll-O-Death sites.
 
N

Neredbojias

Only if you want the text centered as well. As per examples OP gave
this did not seem to be desired.... but was common with the ol'
GeoCities Scroll-O-Death sites.

Text and images - any inline stuff. Whatever the case may be, it's
easy enough to try the css out and adjust it to suit.
 
A

Adrienne Boswell

No, we do not wish the text centered. Only the web page is centered.
Yes, same as this too: http://geocities.yahoo.com/

As others have said, use a wrapper.
Please tell me how do I do it?
<body>
--------site align in center of web page----
</body>

No, you don't want to do this on the page itself, you want to use an
external stylesheet, eg:

#wrapper {margin-left:10%; margin-right:10%; border:1px solid #c0c0c0;}

And in your page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css">
</head>
<body>
<div id="wrapper">
...
</div>
</body>
</html>
 
J

Jonathan N. Little

No, we do not wish the text centered. Only the web page is centered.
Yes, same as this too: http://geocities.yahoo.com/
Please tell me how do I do it? <body>
--------site align in center of web page----
</body>

I just did!


CSS:

div.wrapper { width: 80%; margin-left: auto; margin-right: auto; }

HTML

<body>
<div class="wrapper">
<h1>Your Page</h1>
<p>The rest of your content...</p>
....

</div> <!-- end of div "wrapper" -->
</body>
 
D

dorayme

"Jonathan N. Little said:
ARC wrote: ....

I just did!


CSS:

div.wrapper { width: 80%; margin-left: auto; margin-right: auto; }

<div class="wrapper">
<h1>Your Page</h1>
<p>The rest of your content...</p>
...

</div> <!-- end of div "wrapper" -->

And in addition, put a strict doctype on your HTML.

And add

..wrapper {text-align: left;}

if you are having any trouble with text not lefting.
 
W

William Gill

Jonathan said:
I just did!


CSS:

div.wrapper { width: 80%; margin-left: auto; margin-right: auto; }

HTML

<body>
<div class="wrapper">
<h1>Your Page</h1>
<p>The rest of your content...</p>
...

</div> <!-- end of div "wrapper" -->
</body>

I believe the same effect can be achieved by styling the <body> tag
directly (w/o a wrapper). i.e.
body { width: 80%; margin-left: auto; margin-right: auto; }
vice
div.wrapper { width: 80%; margin-left: auto; margin-right: auto; }

OP if you are not doing much other styling you can add this via a
<style> tag, or the style attribute of the <body> tag. A basic CSS
tutorial should acquaint you with the hows.
 
J

Jonathan N. Little

dorayme said:
And in addition, put a strict doctype on your HTML.

Absolutely

And add

.wrapper {text-align: left;}

if you are having any trouble with text not lefting.

Should not be a issue unless one tried the misguided approach of
centering blocks with the text-align property.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top