views:

50

answers:

3

First the result in Firefox 4 Beta 8:

Button vs Div

The former element shown is a button with an img the latter is a div with an img. As you can see in the former case there is some strange space between the border of the img and the border of the button. I wonder how I can remove it.

Here the CSS file:

* {
    margin: 0;
    padding: 0;
}

button, img, div {
    border: 1px solid black;
}

img {
    display: block;
}
A: 

I think you have to set a width for the div

Pr0fess0rX
My question is referring to the strange space in the **former** case. The latter is perfectly clear ;)
nikic
A: 

It looks like the padding you're asking for is not being applied. Have you tried setting it explicitly on the button?

Donal Fellows
I gave the button a `padding: 0 !important`, it still didn't work.
nikic
+4  A: 

Testing the above testcase in other browsers has shown that this probably isn't a CSS issue but a bug in Firefox. After a little bit of research I found this bug report: Bug 140563 - <button> ignores CSS style padding:0

In that bug report there is a fix for the problem:

button::-moz-focus-inner {padding:0; border:0}
nikic