Unable to align two specific DIV tags with CSS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cssascii
    New Member
    • Jul 2008
    • 3

    #1

    Unable to align two specific DIV tags with CSS

    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



    The two div tags in question are <div class="Employme ntHighlightCont ainer">

    <div class="LogoTopR ow">
    Last edited by cssascii; Jul 28 '08, 11:11 PM. Reason: adding more info
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    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.

    Comment

    • cssascii
      New Member
      • Jul 2008
      • 3

      #3
      I figured it out based on this link:


      Code:
      To center a table, you need to set the margins, like this: 
      
        table.center {margin-left:auto; margin-right:auto;}
      And then do this: 
      
        <table class="center">
          ...
        </table>
      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: 
      
        body {text-align:center;}

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        Not only did he say the same thing I did, he's in my home town, too. Who is this guy?

        Comment

        • cssascii
          New Member
          • Jul 2008
          • 3

          #5
          Which guy? What do you mean?

          Comment

          • drhowarddrfine
            Recognized Expert Expert
            • Sep 2006
            • 7434

            #6
            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.

            Comment

            Working...