• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

center align website using css

I am having problems centering my website, i want to do it in CSS so it changes all the pages.

I used the following code below in my css, and upon saving i saw it take effect in dreamweaver and the page centered but on the browser it's still left aligned.
BODY {
	FONT-FAMILY: Tahoma, Arial, Verdana, sans-serif;
	FONT-SIZE: 11px;
	COLOR: #3B3B3B;
	background-image: url(i/tile.gif);
	margin-left: auto;
	margin-right: auto;
	text-align: center;
}

Open in new window

0
newmie22
Asked:
newmie22
  • 2
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
This is what I normally do and it's used on a lot of web sites.  Since the <body> is the whole screen, you can't use it to center your content in CSS.  Instead, most people add a 'wrapper' DIV around their entire content inside the body like below.  The fixed width and auto margins center that div inside the body.
body {
  margin: 0;
  color:#000000;
  background-color: #ffffff;
  }

#wrap {
  position:relative;
  width: 960px; 
  margin-left: auto; 
  margin-right: auto;
  } 

Open in new window

0
 
newmie22Author Commented:
Thanks for the advice.  When i try that the page now goes back to being left aligned in dreamweaver and is still left aligned in the browser
0
 
newmie22Author Commented:
Nevermind, this worked! Forgive my stupidity i left off the ending div to wrap the site! Thank you.
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now