Reputation: 3074
I have this code in my html :
<img src="images/amazon.png" width="40px" />
The image is originally 110 by 80, but I am scaling it down to 40px wide. This works fine in chrome and firefox, scaling it down to 40 by 15.
But in IE9/10 it still shows the original size i.e. 110 by 80.
Why is this happening, and how do I resolve this ?
Upvotes: 2
Views: 69
Reputation: 168685
If you're using the old-style HTML attributes to specify width
, etc, the syntax does not include px
. It needs to be:
<img src="images/amazon.png" width="40" />
However, it is considered bad practice to use these attributes these days -- they are deprecated in favour of CSS styles.
CSS can be specified in the element, so if you need to specify it there, you would write is as follows:
<img src="images/amazon.png" style="width:40px;" />
Note that since this is CSS styling, the px
is required here.
Even better would be to specify the width in a separate CSS file (alongside the rest of your page layout styles).
Upvotes: 1