Solved

center contents of webpage for all browsers and screen sizes

Posted on 2006-06-19
3
359 Views
Last Modified: 2013-12-16
I am trying to create a website that has the contents in the center of the page with a different background color for the area to the left of the left hand-margin as well as a different color for the area to the right of the right-hand margin. An example of what I am talking about can be found at www.icemiller.com.  It appears that I accomplished my goal when I am in Dreamweaver but when I view the page in internet explorer some of the controls and flash movies are in the margins and are not centered on the page. Can anyone explain how I can fix this problem? I am new to web development so any help would be greatly appreciated.

Thanks,

Ryan Wade
0
Comment
Question by:tankwade44
[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
3 Comments
 
LVL 25

Accepted Solution

by:
Rouchie earned 125 total points
ID: 16940440
Okay, what's happening is that the background of the body is set to grey, and then within the body either a div or table is used to stop the content stretching out to the width of the screen.  As DIV's are the recommended practice, my example below uses that approach.  The background color of the DIV is set to white, which makes it appear that there is a grey border.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Title Here</title>
    <style type="text/css">
        body {margin:0; padding:0; background-color:#dddddd;}
        .container {margin:0 auto; width:600px; background-color:#ffffff; text-align:center; border:1px solid #aaaaaa;}
    </style>
</head>
<body>
    <div class="container">
        <h1>My Page</h1>
        <p>Page content here.</p>
    </div>
</body>
</html>
0
 

Author Comment

by:tankwade44
ID: 16942974
Thanks a lot for your help.  I used the code above and it worked perfectly. I appreciate your help very much.

Ryan Wade
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 16943013
You're welcome!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

726 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