The auto value on styles

This issue was fixed in Internet Explorer 7 beta 2.

Many styles are allowed to accept the auto value. It allows you to override styles for elements. Say for example, you set the width of all links to be 100% (usually combined with display:block;), but then for one or two links, you want their width to be whatever it would be if you had never set the width. Well, you can use auto:
a.nowidth { width: auto; }
That's great. We're all happy.

Now, how about margins. The default values for left and right margins (on most elements) is '0', as stated by the CSS specifications. If you now set the left and right margins on a block element to auto, they have an equal value that should be calculated, so they should end up equal. Meaning that if the element is not using 100% of the width of its parent, the element should be centred, in the middle of its parent. Or at least, it would, if only IE bothered to implement it. But no. auto is not allowed to override styles properly, and IE always knows best. Honest.

Note: Again, this is a case of IE 6 following the standard, but only as long as you use the HTML strict doctype, not the XHTML doctype with the XML conformance tag. There are more examples of this, such as white-space:pre; being ignored except with HTML strict doctypes, and styles not being inherited inside tables. For some reason, they seem to think that when you ask for an even more standards compliant response, what you actually want is a less standards compliant response. Of course, the other browsers do what you ask, giving inconsistent rendering - caused once again by a ridiculous decision made by IE.

Demo: The link that says "Move on to the next page in this article > >" should be positioned in the centre of the page.

Workaround: Also setting the text-align: center; on the element, then overriding that for child elements should centre align. You can also use HTML strict - that still won't help in IE 5.x.

Don't click this link unless you want to be banned from our site.