0

Image size is fixed to 42*42. But if we hover over anchor tag in inspect element, size is shown as 42*46. Why the size of anchor tag increases? Is it because I am using float?

<a href="https://www.w3schools.com" 
style="float:left"><img src="https://www.w3schools.com/tags/smiley.gif" alt="Smiley face" width="42" height="42"></a>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
AKNair
  • 1,369
  • 1
  • 12
  • 24

1 Answers1

1

It's because of the display and vertical-align of img. Setting the vertical-align on the following works:

<a href="https://www.w3schools.com" style="float:left">
  <img src="https://www.w3schools.com/tags/smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align: middle;" />
</a>
Soolie
  • 1,812
  • 9
  • 21