How can I automatically center a container <div> in IE8?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samuel Hill
    New Member
    • Jan 2011
    • 4

    How can I automatically center a container <div> in IE8?

    I am working with IE8 in quirks mode...

    I have styles cascading from my Firefox style-sheet which include:
    Code:
    #container {position:relative; width:1007px; margin-right:auto; margin-left:auto;}       
     
    #textbin {width:720px; position:relative; margin-right:auto; margin-left:auto;}
    Apparently I'm not doing something right, or auto-margining does not work in IE8.
    Is this the case? If so, how can I get around this limitation?
  • Samuel Hill
    New Member
    • Jan 2011
    • 4

    #2
    For those of you who were wondering like I was, this is the reply I got on http://www.stackoverflow.com:

    The old-school hack-y way to do it was to add text-align:center to the parent of the div you want to center. Of course you'll need to then specifically declare a text-align property for the child elements if you don't want them to be center aligned, as text-align is going to be inherited by child elements.

    JMC Creative

    Comment

    • AutumnsDecay
      New Member
      • Mar 2008
      • 170

      #3
      Using <center> tags didn't work?

      Comment

      • JKing
        Recognized Expert Top Contributor
        • Jun 2007
        • 1206

        #4
        <center> is a deprecated tag and I wouldn't recommend using it.

        Comment

        • Samuel Hill
          New Member
          • Jan 2011
          • 4

          #5
          I've never heard of the <center> tag.

          Comment

          • AutumnsDecay
            New Member
            • Mar 2008
            • 170

            #6
            It's still XHTML compliant though.

            Comment

            • JKing
              Recognized Expert Top Contributor
              • Jun 2007
              • 1206

              #7
              Yes, it will work but it is only supported by browsers for backwards compatibility. They are deprecated for a reason, because they are trying to phase them out.

              I would personally rather do it right and avoid having a page that breaks and having to do the rework that will come when browsers stop supporting it.

              Comment

              • Samuel Hill
                New Member
                • Jan 2011
                • 4

                #8
                good point...

                Comment

                Working...