Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

center align website using css

Posted on 2010-09-17
4
Medium Priority
?
276 Views
Last Modified: 2012-05-10
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
Comment
Question by:newmie22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 33704114
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
 

Author Comment

by:newmie22
ID: 33704145
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
 

Author Closing Comment

by:newmie22
ID: 33704261
Nevermind, this worked! Forgive my stupidity i left off the ending div to wrap the site! Thank you.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 33704561
You're welcome!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question