HAYATO SHIBA
HAYATO SHIBA

Reputation: 151

width and height of img in html doesn't work

my html is below.

    <img src="something" alt="" width="1px" height="1px" border="0" />

I think it shows image of 1px × 1px. but actually the code shows below.

 <img src="something" alt="" border="0" width="438" height="438" srcset="something?zoom=1.25&amp;resize=438%2C438&amp;" src-orig="something?resize=1%2C1&amp;" scale="1.25">

Why do I have the error? Why does not image of 1px × 1px show on my site? Please help me...

Upvotes: 0

Views: 1945

Answers (1)

caramba
caramba

Reputation: 22490

dont write px try this :

 <img src="http://lorempixel.com/output/abstract-q-c-640-480-7.jpg" alt="" width="1" height="1" border="0" />

Actually it should also work with px. So what could be the reason that your code isn't working is you are either overwriting the rule with some other CSS or javascript. Turn off CSS and or javascript if it still isn't working and see why.

See here if you have added CSS rules it will not work:

img {
  width: 100%;
  height: 500px;
}
<img src="http://lorempixel.com/output/abstract-q-c-640-480-7.jpg" alt="" width="1" height="1" border="0" />

Upvotes: 1

Related Questions