7

All major browsers except FF render images with invalid src attribute within it's dimensions as specified by CSS or by width / height attributes. Only FF will render the alt attribute as it were text node, ignoring dimensions, which breaks layout in many cases.

Is there a way to force FF to render image within specified dimensions?

2
  • 1
    Code? Example? Screenshot? Anything? Commented Jan 18, 2013 at 10:03
  • 1
    Not sure but have you tried adding display:inline-block to the image css? Perhaps when FF converts it to a text node it becomes functionally the same as a span and ignores width and height css? Commented Jan 18, 2013 at 10:03

3 Answers 3

11

You should change the DOM element representation

img{ display:block; } 

or

img{ display:inline-block; } 

or

img{ float:left; } 
Sign up to request clarification or add additional context in comments.

Comments

2

try adding this rule to the css:

 @-moz-document url-prefix(http), url-prefix(file) { img:-moz-broken{ -moz-force-broken-image-icon:1; width:100px; height:100px; } } 

jsfiddle sample

source from: https://stackoverflow.com/a/6744791/1915183

2 Comments

I combined :-moz-broken with display: inline-block. Works for me!
Great suggestion, I always wanted back the icon for broken images, it makes it much easier to locate them quickly... thanks. Better remove the width and height from CSS and just use the self width and height attributes from each image.
1

try to write width: and height attribute in img tag itself or use !important for width and height in CSS

2 Comments

Yes, thanks. Setting attributes didn't work, but adding !important to declaration in CSS made it work, along with overflow:hidden.
The !important declaration is one of the worst ideas ever created, I can't believe someone would suggest that. Fix the root issue with the proper methods instead, !important tag was created for inept developers exclusively.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.