0.1rem top/bottom is not equal with an image

22 hours ago 4
ARTICLE AD BOX
.box{ background-color: red; padding: 0.1rem 1rem; } img{ width: 24px; height: 24px; vertical-align: middle; } <div class="box"> <div class="logo"> <img src="https://picsum.photos/200" alt=""> </div> </div>

with 0.1 rem, its 8 and 4 pixels (the black dots)
pixels visual of the top/bottom spaces

with 0.2 rem, its 12 pixels
pixels visual of the top/bottom spaces

Ibrahim Ali's user avatar

3

.1rem is 1.6px .. if you are getting 8px or 4px, it means you have more CSS to share with us

2026-05-06 11:59:56 +00:00

Commented 20 hours ago

@TemaniAfif the 8px and 4px are just reference to the attached zoomed images, basically there is more space on the top of the image than bottom when using 0.1rem, but not the case with 0.2rem or even 0.11rem

2026-05-06 12:19:55 +00:00

Commented 19 hours ago

@Paulie_D he's already applying vertical-align to remove that space

2026-05-06 12:21:59 +00:00

Commented 19 hours ago

Read Entire Article