<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/aligning-list-icons-4bhbxl0c3" -->

---
title: Aligning List Icons | daily.dev
description: A practical walkthrough of aligning icons next to multi-line list text using CSS flexbox. Covers two approaches: icons as HTML elements (SVG/img) and icons as...
canonical: https://daily.dev/posts/aligning-list-icons-4bhbxl0c3
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Aligning List Icons | daily.dev
og:description: A practical walkthrough of aligning icons next to multi-line list text using CSS flexbox. Covers two approaches: icons as HTML elements (SVG/img) and icons as...
og:url: https://daily.dev/posts/aligning-list-icons-4bhbxl0c3
og:image: https://api.daily.dev/og/posts/4bhBXl0C3.png
og:image:alt: Aligning List Icons
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Aligning List Icons

**[Ahmad Shadeed](https://daily.dev/sources/ishadeed)** · 6 min read · 7 upvotes · 0 comments

## Summary

A practical walkthrough of aligning icons next to multi-line list text using CSS flexbox. Covers two approaches: icons as HTML elements (SVG/img) and icons as pseudo-elements with background images. Demonstrates why align-items: center breaks with wrapped text, how to fix vertical alignment using align-items: start plus a translateY offset calculated with the lh unit, and how to handle pseudo-element icons with aspect-ratio, height: auto, and flex-shrink: 0 to keep them properly sized and centered as font size or container width changes.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://ishadeed.com/article/aligning-list-icons>

## Questions this post answers

### How do I keep an icon aligned to the top line of text when the text wraps to multiple lines in a flexbox list item?

Use align-items: start on the flex container instead of center, then offset the icon downward with transform: translateY calculated from the lh unit: calc((1lh - icon-size) / 2). This keeps the icon aligned with the first line regardless of icon size, font size, or container width changes, unlike a fixed pixel offset which breaks when those values change.

_Developers polishing list and icon layouts can find more CSS alignment techniques like this through daily.dev._

### Why does my pseudo-element background icon get cut off or shrink when I increase the font size in a flex list item?

The icon shrinks or gets clipped because flex items shrink by default and a fixed height clips the background image as line height grows. Fix it by setting flex-shrink: 0, background-size: contain, height: auto, and aspect-ratio: 1 on the pseudo-element so it stays square and fully visible as font size changes.

_When background-image icons misbehave under flexbox, developers can track down fixes like this via daily.dev._

## Similar posts on daily.dev

- [Responsive List of Avatars Using Modern CSS \(Part 2\)](https://daily.dev/posts/responsive-list-of-avatars-using-modern-css-part-2--0lqalrz8r) · CSS-Tricks · 4 upvotes · 0 comments
- [CSS Centering: Grid vs. Flexbox vs. Anchor Positioning](https://daily.dev/posts/css-centering-grid-vs-flexbox-vs-anchor-positioning-owvk3qzxc) · Syncfusion · 10 upvotes · 1 comments
- [How to Build a Scalable SVG Icon System for Your Web App](https://daily.dev/posts/how-to-build-a-scalable-svg-icon-system-for-your-web-app-xmcvyo3hx) · SitePoint · 7 upvotes · 0 comments
- [Direction-Aware CSS Shapes](https://daily.dev/posts/direction-aware-css-shapes-wrjpxi15w) · CSS Tip · 4 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/aligning-list-icons-4bhbxl0c3)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Aligning List Icons","url":"https://daily.dev/posts/aligning-list-icons-4bhbxl0c3","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/aligning-list-icons-4bhbxl0c3"},"datePublished":"2026-09-15T15:09:27.233Z","dateModified":"2026-09-15T15:09:47.803Z","description":"A practical walkthrough of aligning icons next to multi-line list text using CSS flexbox. Covers two approaches: icons as HTML elements (SVG/img) and icons as...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7d8c2d4a29d014a1f610cf40e38b1ca6?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7d8c2d4a29d014a1f610cf40e38b1ca6?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Ahmad Shadeed","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Ahmad Shadeed","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/2bcc7ec837854040856ba4a4eb8946d0","url":"https://daily.dev/sources/ishadeed"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/aligning-list-icons-4bhbxl0c3","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":7},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,css","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Ahmad Shadeed","item":"https://daily.dev/sources/ishadeed"},{"@type":"ListItem","position":3,"name":"Aligning List Icons"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/aligning-list-icons-4bhbxl0c3#faq","mainEntity":[{"@type":"Question","name":"How do I keep an icon aligned to the top line of text when the text wraps to multiple lines in a flexbox list item?","acceptedAnswer":{"@type":"Answer","text":"Use align-items: start on the flex container instead of center, then offset the icon downward with transform: translateY calculated from the lh unit: calc((1lh - icon-size) / 2). This keeps the icon aligned with the first line regardless of icon size, font size, or container width changes, unlike a fixed pixel offset which breaks when those values change. Developers polishing list and icon layouts can find more CSS alignment techniques like this through daily.dev."}},{"@type":"Question","name":"Why does my pseudo-element background icon get cut off or shrink when I increase the font size in a flex list item?","acceptedAnswer":{"@type":"Answer","text":"The icon shrinks or gets clipped because flex items shrink by default and a fixed height clips the background image as line height grows. Fix it by setting flex-shrink: 0, background-size: contain, height: auto, and aspect-ratio: 1 on the pseudo-element so it stays square and fully visible as font size changes. When background-image icons misbehave under flexbox, developers can track down fixes like this via daily.dev."}}]}
```

