Mrs. Yanti’s price board with Mr. Karim’s strings on each line: set vertical-align on an icon, a photo or a button in your line of text, and the browser’s…
This property is misused more than any: reached for to centre blocks (it never works) and behind the "mysterious gap under an <img>". Once you see the line’s lines it uses, and that middle is not the line’s middle, hours of debugging are over.
vertical-align aligns to the line’s lines, not to its container
vertical-align: middle on a div to centre it changes nothing vertical-align does not apply to blocks, and on line content it aligns to the line, not the box. Use display: flex; align-items: center or display: grid; place-items: center on the box.<img> An inline image sits on the baseline; below it the line keeps letter-tail room. Set vertical-align: bottom (or top/middle) on the image, or display: block. Tailwind’s preflight already sets img { display: block }, which is why the gap is rare in Tailwind projects.middle is exactly the line’s middle middle = the box’s centre at the parent’s baseline + ½ x-height, the middle of the lowercase letters. It is a few pixels off the line’s middle; for a true centre use flex/grid.baseline → top → bottom The icon snaps to the top and then the bottom of the whole line (the grey strings), not to the board.middle, look at "the middle string to the line’s middle" The orange string (baseline + ½ x-height) is not the line’s middle. That is why a "middle" icon can still look off.frame: remove the gap under the photo An inline photo sits on the baseline and leaves letter-tail room. bottom, top, middle or display: block removes it.-4px or 30% A length shifts the box from the baseline (positive = up). A percentage is taken of the element’s own line-height.