I am doing some preliminary testing of IE8, and it seems that the old method of using margin: 0 auto; not working in all cases in IE8.
The following HTML part gives a centered button in FF3, Opera, Safari, Chrome, IE7 and is compatible with IE8, but NOT in the IE8 standard:
<div style="height: 500px; width: 500px; background-color: Yellow;"> <input type="submit" style="display: block; margin: 0 auto;" /> </div>
(In the process, I can add an explicit width to the button).
So the question is: which browsers are correct? Or is this one of those cases where the behavior is undefined?
(I think all browsers are wrong - shouldn't the button be 100% wide if it "displays: block"?)
UPDATE: I will be dunce. Since the input is not a block level element, I just had to contain it in a div with "text-align: center". Having said that, for the sake of curiosity, I would still like to know if the button should or should not be focused in the above example.
FOR BOUNTY: I know that I am doing strange things in the example, and as I point out in the update, I just had to center it. For generosity, I would like to get links to specifications that meet:
If I set "display: block", should the button be 100% wide? Or is it undefined
Since the display is a block, it should "margin: 0 auto;" center button or not, or undefined?
html css internet-explorer-8
stusmith Mar 19 '09 at 2:05 p.m. 2009-03-19 14:05
source share