margin: auto

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    margin: auto

    Updating my bag of tricks again.

    What's the level of support for margin: auto. Is this widely
    supported now amongst almost all browsers?

    It's a common request to have a "centered" page. I don't remember
    which major browser didn't support margin: auto, but there was a common
    hack with some "text-aligns". Is it time to drop the hack?

    Jeff
  • Rik Wasmus

    #2
    Re: margin: auto

    On Fri, 22 Feb 2008 21:50:42 +0100, Jeff <jeff@spam_me_n ot.comwrote:
    Updating my bag of tricks again.
    >
    What's the level of support for margin: auto. Is this widely
    supported now amongst almost all browsers?
    Save MSIE6 and lower.
    It's a common request to have a "centered" page. I don't remember
    which major browser didn't support margin: auto, but there was a common
    hack with some "text-aligns". Is it time to drop the hack?
    Nope, MSIE6 still needs it. margin:auto on the element for any other
    browser, text-align:center on the parent element for MSIE6.
    --
    Rik Wasmus

    Comment

    • dorayme

      #3
      Re: margin: auto

      In article <13rudd4o354c1a 2@corp.supernew s.com>,
      Jeff <jeff@spam_me_n ot.comwrote:
      Updating my bag of tricks again.
      >
      What's the level of support for margin: auto. Is this widely
      supported now amongst almost all browsers?
      >
      It's a common request to have a "centered" page. I don't remember
      which major browser didn't support margin: auto, but there was a common
      hack with some "text-aligns". Is it time to drop the hack?
      IE 6 is the one to worry about. It will not centre a block with
      margin: auto and a width.

      --
      dorayme

      Comment

      • Bergamot

        #4
        Re: margin: auto

        Rik Wasmus wrote:
        On Fri, 22 Feb 2008 21:50:42 +0100, Jeff <jeff@spam_me_n ot.comwrote:
        >
        > It's a common request to have a "centered" page. I don't remember
        >which major browser didn't support margin: auto, but there was a common
        >hack with some "text-aligns". Is it time to drop the hack?
        >
        Nope, MSIE6 still needs it.
        Nope, IE6 does *not* need it, at least not in standards mode.
        Margin:auto works perfectly fine. IE5.x doesn't grok it, but who cares?

        You shouldn't be coding for quirks mode any more anyway.

        --
        Berg

        Comment

        • Bergamot

          #5
          Re: margin: auto

          dorayme wrote:
          In article <13rudd4o354c1a 2@corp.supernew s.com>,
          Jeff <jeff@spam_me_n ot.comwrote:
          >>
          > What's the level of support for margin: auto. Is this widely
          >supported now amongst almost all browsers?
          >
          IE 6 is the one to worry about. It will not centre a block with
          margin: auto and a width.
          bollocks

          I use margin:auto all the time. It works perfectly fine in IE6.

          --
          Berg

          Comment

          • Rik Wasmus

            #6
            Re: margin: auto

            On Fri, 22 Feb 2008 23:41:21 +0100, Bergamot <bergamot@visi. comwrote:
            Rik Wasmus wrote:
            >On Fri, 22 Feb 2008 21:50:42 +0100, Jeff <jeff@spam_me_n ot.comwrote:
            >>
            >> It's a common request to have a "centered" page. I don't remember
            >>which major browser didn't support margin: auto, but there was a common
            >>hack with some "text-aligns". Is it time to drop the hack?
            >>
            >Nope, MSIE6 still needs it.
            >
            Nope, IE6 does *not* need it, at least not in standards mode.
            Ah, most of my pages are valid strict 4.01, did seem to run into troubles
            a time ago, maybe I used a lousy doctype back then...
            Margin:auto works perfectly fine. IE5.x doesn't grok it, but who cares?
            You shouldn't be coding for quirks mode any more anyway.
            Amen.
            --
            Rik Wasmus

            Comment

            • Ben Bacarisse

              #7
              Re: margin: auto

              Jeff <jeff@spam_me_n ot.comwrites:
              dorayme wrote:
              >In article <13rudd4o354c1a 2@corp.supernew s.com>,
              > Jeff <jeff@spam_me_n ot.comwrote:
              >>
              >> Updating my bag of tricks again.
              >>>
              >> What's the level of support for margin: auto. Is this widely
              >>supported now amongst almost all browsers?
              >>>
              >> It's a common request to have a "centered" page. I don't
              >>remember which major browser didn't support margin: auto, but there
              >>was a common hack with some "text-aligns". Is it time to drop the
              >>hack?
              >>
              >IE 6 is the one to worry about. It will not centre a block with
              >margin: auto and a width.
              >
              OK, I'm totally mixed up.
              >
              I've got IE6 on XP. It centers fine with margin: 0 auto, when I
              have, it in standards mode and not in quirks mode.
              That is what happens. See http://www.quirksmode.org/css/quirksmode.html
              for a longer list of the differences.

              As has already been said, if you use a standards-triggering DOCTYPE,
              then IE6 is must less of a pain. I would not recommend doing anything
              else, although there may be situations in which you are forced to*.

              * Hmm... the most obvious is some managerial insistence on XHTML with
              an XML prologue. This will trigger quirks mode.

              --
              Ben.

              Comment

              Working...