soundswaste
soundswaste

Reputation: 3074

Image scaledown not working in IE

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.

enter image description here

But in IE9/10 it still shows the original size i.e. 110 by 80.

enter image description here

Why is this happening, and how do I resolve this ?

Upvotes: 2

Views: 69

Answers (1)

Spudley
Spudley

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

Related Questions