servioret wedijotu servioret wedijotu - 16 days ago 6
CSS Question

Why div area still bigger more than image css?

Why div area still bigger more than image css ?



<div style="padding: 0px 0px;display: inline-table;background: red;">
<img src="http://static.adzerk.net/Advertisers/3ce23fa868ea401dac7e2fcfda5ec312.png" style="height: 70px;padding: 0;margin: 0; ">
</div>




https://i.stack.imgur.com/WHDU3.jpg

How can i do for set div area to fit image ?

Answer

IMG - is inline element, so it behaves differently than block type elements. You can override that by setting it's display to block

If you replace "inline-table" for "inline-block" for the div and set display:block for img - everything will be fine. There is a good description in this answer on SO