Connecting Tech Pros Worldwide Help | Site Map

Unable to align two specific DIV tags with CSS

Newbie
 
Join Date: Jul 2008
Posts: 3
#1: Jul 28 '08
Hello all,

I am new to the forum. I have a question for you guys. I have a webpage coded in strict XHTML 1.0 and CSS 2.1, both validated. Unfortunately the top section of my page does not want to align with the title and the body of the page. The layout looks completely fine in IE 7.0, but when I open Mozilla 5.0 version 2.0.0.16 and the top content is slightely off center from the rest of the page, as in the table is not centered, yet the cells and their contents are? Any ideas?

The following two DIV tags are giving me trouble and here is the link to my page. I have pinpointed the problem down to those two DIV tags and their relationship with the CSS code, but I can't figure out what it could be.

Thanks for your help

http://www.belorussov.com

The two div tags in question are <div class="EmploymentHighlightContainer">

<div class="LogoTopRow">
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,562
#2: Jul 29 '08

re: Unable to align two specific DIV tags with CSS


You are applying all the centering stuff to the containers but not to the table itself, so: table{margin:0 auto}

text-align cannot be applied to a table.

Firefox is performing correctly. IE is not.
Newbie
 
Join Date: Jul 2008
Posts: 3
#3: Jul 29 '08

re: Unable to align two specific DIV tags with CSS


I figured it out based on this link:
http://www.granneman.com/webdev/codi.../centertables/

Expand|Select|Wrap|Line Numbers
  1. To center a table, you need to set the margins, like this: 
  2.  
  3.   table.center {margin-left:auto; margin-right:auto;}
  4. And then do this: 
  5.  
  6.   <table class="center">
  7.     ...
  8.   </table>
  9. At this point, Mozilla and Opera will center your table. Internet Explorer 5.5 and up, however, needs you to add this to your CSS as well: 
  10.  
  11.   body {text-align:center;}
  12.  
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,562
#4: Jul 29 '08

re: Unable to align two specific DIV tags with CSS


Not only did he say the same thing I did, he's in my home town, too. Who is this guy?
Newbie
 
Join Date: Jul 2008
Posts: 3
#5: Jul 30 '08

re: Unable to align two specific DIV tags with CSS


Which guy? What do you mean?
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,562
#6: Jul 30 '08

re: Unable to align two specific DIV tags with CSS


The guy who runs the site you linked to. He's in my city. As it turns out, he teaches at the school I went to, also, but I don't know him.
Reply