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
Solved

center contents of webpage for all browsers and screen sizes

Posted on 2006-06-19
3
346 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
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
create a website 10 79
USPS CityStateLookup question 3 83
Strange space issue in Chrome browser 8 114
Grunt No Clean Targets 6 184
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
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…

840 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