471,603 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 software developers and data experts.

Unable to center div

ok First time here and this is no doubt something really obvious I am overlooking. I use the following css and html to try and center a container div on a page. For the life of me it will not center in FF though. Any ideas??

Expand|Select|Wrap|Line Numbers
  1. html, body 
  2. {
  3.         margin: 0 auto;
  4.         padding: 0;
  5.     text-align: center;
  6.     font: xx-small Verdana, Geneva, Arial, Helvetica, sans-serif;
  7.     background-color:#cccccc;
  8.     height: 100%;
  9.         margin-bottom: 1px;
  11. #container{
  12.     width: 768px;
  13.     text-align: left;
  14.     margin-left: auto;
  15.     margin-right: auto;    
  16.     background-color: #fff;        
  17. }
<!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">
<title>center page</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<div id="container" >
Oct 24 '07 #1
7 2406
7,435 Expert 4TB
#container is centered.
Oct 24 '07 #2
Weird, the plot thickens, on my IE it is centered but not on my FF
Oct 24 '07 #3
7,435 Expert 4TB
Clear your cache and refresh.
Oct 24 '07 #4
5,058 Expert 4TB

Just tried this. Worked on both IE7 and Firefox 2.
Oct 24 '07 #5
thanks everyone for checking. Was doing my head in as knew the code was right.
Oct 25 '07 #6
I have managed to come back to this after being distracted. Still experiencing this weird non centering in FF. On FF, although body margins are set to 0 auto and container margins all 0 it is pushing the page across to the right instead of centering it as in IE.

Any ideas?
Oct 25 '07 #7
7,435 Expert 4TB
I looked at it again in both FF and IE6 and IE7 and they all look identical.
Oct 25 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Arun Nair | last post: by
5 posts views Thread by db2sysc | last post: by
3 posts views Thread by annoir | last post: by
reply views Thread by deepaks85 | last post: by
6 posts views Thread by =?Utf-8?B?U3RlZmFuIEJhcmxvdw==?= | last post: by
2 posts views Thread by yangtono | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.