Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

center contents of webpage for all browsers and screen sizes

Posted on 2006-06-19
3
Medium Priority
?
363 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 500 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

636 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