# The lh Unit Solves Icon and Label Alignment

Original title: Better Icon and Label Alignment

> Hacker News story 49727537 · language: en · submitted 2026-09-16
> Web version: https://zeli.app/story/49727537
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 41 · by [eustoria](<https://news.ycombinator.com/user?id=eustoria>) · 💬 8
[original](<https://ishadeed.com/article/aligning-list-icons/>) · [HN discussion](<https://news.ycombinator.com/item?id=49727537>)

## Summary

When list items have icons and text wraps, centering the icon looks wrong. Using align-items: start causes the icon to sit too high because of the font's line height. The fix: calculate the offset with calc((1lh - icon-size) / 2) and apply it via transform: translateY. This works for any icon size, font size, or container width. For pseudo-element icons, also set flex-shrink: 0, aspect-ratio: 1, and height: auto.

## Key quote

> If we can get the line-height value and we have a known icon size, we can make the offset relative to them.

## HN discussion (8 comments)

### [pveierland](<https://news.ycombinator.com/item?id=49749683>)

> There's new CSS capabilities [0] that can help solve this problem better now via alignment-baseline [1] and text-box-trim [2].
>
> [0] https://www.w3.org/TR/css-inline-3/#leading-trim
>
> [1] https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/P...
>
> [2] https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/P...

### [systoll](<https://news.ycombinator.com/item?id=49751273>)

> `list-style-image` seems like a more straightforward solution to the same problem.
>
> Or a negative text-indent, if you want arbitrary content rather than just a tick.

### [LinguaBrowse](<https://news.ycombinator.com/item?id=49750826>)

> Playing around with the demos, none of the solutions seem very centred at all?
>
> I think the lh unit is surely part of the puzzle, but something more is needed. It assumes that the ascent and descent are symmetrical, for one thing.

---

## Cite

- Page: https://zeli.app/story/49727537
- Date: 2026-09-16
- Source: ishadeed.com (https://ishadeed.com/article/aligning-list-icons/)
- Hacker News: https://news.ycombinator.com/item?id=49727537

## Other languages

- zh: https://zeli.app/zh/story/49727537 · markdown: https://zeli.app/zh/story/49727537.md
- ja: https://zeli.app/ja/story/49727537 · markdown: https://zeli.app/ja/story/49727537.md
- ko: https://zeli.app/ko/story/49727537 · markdown: https://zeli.app/ko/story/49727537.md
- de: https://zeli.app/de/story/49727537 · markdown: https://zeli.app/de/story/49727537.md
- es: https://zeli.app/es/story/49727537 · markdown: https://zeli.app/es/story/49727537.md
- ru: https://zeli.app/ru/story/49727537 · markdown: https://zeli.app/ru/story/49727537.md
