Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / February 2008



Tip: Looking for answers? Try searching our database.

margin: auto

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 22 Feb 2008 20:50 GMT
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 - 22 Feb 2008 21:08 GMT
>    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.
Signature

Rik Wasmus

Bergamot - 22 Feb 2008 22:41 GMT
>>    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.

Signature

Berg

Rik Wasmus - 22 Feb 2008 22:58 GMT
>>>    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
[quoted text clipped - 3 lines]
>
> 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.
Signature

Rik Wasmus

dorayme - 22 Feb 2008 21:18 GMT
>    Updating my bag of tricks again.
>
[quoted text clipped - 4 lines]
> 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.

Signature

dorayme

Bergamot - 22 Feb 2008 22:43 GMT
>>    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.

Signature

Berg

dorayme - 23 Feb 2008 01:35 GMT
> >>    What's the level of support for margin: auto. Is this widely
> >> supported now amongst almost all browsers?
[quoted text clipped - 5 lines]
>
> I use margin:auto all the time. It works perfectly fine in IE6.

Perhaps you missed the words "under some circumstances" <g>

Signature

dorayme

Jeff - 22 Feb 2008 22:53 GMT
>>    Updating my bag of tricks again.
>>
[quoted text clipped - 7 lines]
> 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.

Simple Ex:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<body>
<style type="text/css">
#wrapper{width: 70%;border: 1px solid black;margin: 0 auto}
</style>

<div id="wrapper">some content</div>

</body>
</html>

Is that a quirk in my IE6 (did they fix it for XP) or am I missing
something.

  Thanks to all,
Jeff
Ben Bacarisse - 23 Feb 2008 01:14 GMT
>>>    Updating my bag of tricks again.
>>>
[quoted text clipped - 13 lines]
>   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.

Signature

Ben.

GTalbot - 26 Feb 2008 05:13 GMT
> > In article <13rudd4o354c...@corp.supernews.com>,
>
> >>    Updating my bag of tricks again.
>
> >>    What's the level of support for margin: auto.

margin-left: auto; margin-right: auto;
are very well supported (IE 6 and better) as long as you trigger
standards compliant rendering mode. What Bergamot replied to you is
correct.

> but there was a common
> >> hack with some "text-aligns". Is it time to drop the hack?

Yes, it is time to drop the text-align hack. IE 5.x users represent
now a negligeable %tage in world stats. For those IE 5.x users and
others using an old browsers, what matters (WCAG) is that content
remains accessible and that navigation (links) remains functional.

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

Correct. And I say you can safely remove any text-align hacks.

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
> "http://www.w3.org/TR/REC-html40/strict.dtd">

Why 4.0? Why not 4.01?

> <html>
> <body>
[quoted text clipped - 9 lines]
> Is that a quirk in my IE6 (did they fix it for XP) or am I missing
> something.

No. What you do is fine as far as margin declarations used for
centering... although your #wrapper may be duplicating the role and
function of the body node. Hard to say... as we don't see a real
webpage and can not figure out the real webpage context.

Regards, Gérard
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.