I have a situation where I need HTML img
that is not yet loaded in order to have a given height. The reason is that this height will be used in the calculation, which can work before the image is fully loaded and must remain accurate. I tried the following:
<div>hello<img src='http://example.com/invalid.gif' class="testimage"> there</div>
and put in some css
.testimage { height: 200px; width: 200px; }β
and at least in Firefox 5, the extra space is not displayed (and, oddly enough, the broken image is also not displayed, just an empty space). That is, until I add display: inline-block
. In at least some other browsers, the default inline
display gives the desired result. Is this expected? If so, why?
Here's also jsFiddle: http://jsfiddle.net/uYXD4/
source share