Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Align to Center

Status
Not open for further replies.

Dashsa

Programmer
Aug 7, 2006
110
US
Hello,
I have made a site and I am using CSS for the first time.
My issue is I have created most of the site but now I want to align the site to the center as opposed to the left....

the home page is located here:
and the css file is called Style.css you can view it here:

Thanks for your help
D
 
Hi

To align the site ??? I think you mean to align th whole page content. The usual way is to put the whole content in a [tt]div[/tt] :
Code:
[gray]...[/gray]
</head>
<body>
<div style="width:100%;margin-left:auto;margin-right:auto">

[gray]<!-- content goes here -->[/gray]

</div>
</body>
</html>

Feherke.
 
Thanks,
But I want the site to display in the center of the screen.
I dont want to enter a pixel value for the location.

if i use the code
Code:
#Central{
width:100%;
margin-Left:auto;
margin-Right:auto;
}

It lines the site up to the top left and not in the center...
 
The first thing you'll want to do is validate your HTML. Most browsers will have issues if you haven't specified the DOCTYPE of your page.

- George
 
Put a div around the entire page and give it a specific width that encapsulates every bit of content, but no extra width.

Then give the auto left and right margins to that div.

[monkey][snake] <.
 

Here's the best method I've come across for putting content in the centre of the viewport. It does however require you to specify the width and height of the element.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top