467,165 Members | 1,015 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,165 developers. It's quick & easy.

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
Feb 22 '08 #1
  • viewed: 4929
Share:
6 Replies
On Fri, 22 Feb 2008 21:50:42 +0100, Jeff <jeff@spam_me_not.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
Feb 22 '08 #2
In article <13*************@corp.supernews.com>,
Jeff <jeff@spam_me_not.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
Feb 22 '08 #3
Rik Wasmus wrote:
On Fri, 22 Feb 2008 21:50:42 +0100, Jeff <jeff@spam_me_not.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
Feb 22 '08 #4
dorayme wrote:
In article <13*************@corp.supernews.com>,
Jeff <jeff@spam_me_not.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
Feb 22 '08 #5
On Fri, 22 Feb 2008 23:41:21 +0100, Bergamot <be******@visi.comwrote:
Rik Wasmus wrote:
>On Fri, 22 Feb 2008 21:50:42 +0100, Jeff <jeff@spam_me_not.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
Feb 22 '08 #6
Jeff <jeff@spam_me_not.comwrites:
dorayme wrote:
>In article <13*************@corp.supernews.com>,
Jeff <jeff@spam_me_not.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.
Feb 23 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Alex Bell | last post: by
3 posts views Thread by Blacksmith | last post: by
reply views Thread by GTalbot | last post: by
5 posts views Thread by David Schwartz | last post: by
1 post views Thread by innivive@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.