I have a text and an icon that I want to show together in a div. The icon should always be right next to the text. When there is not enough space for the text, the text should wrap automatically, but the icon should stay next to the text.
I have tried a few solutions but I always run into the problem that as soon as the text wraps, the span will be much wider than it's content, creating a gap between text and icon:
What I want to achieve:
<div style="width: 200px;">
<div style="display: flex;">
<span>Erforderliche Gesamtsumme</span>
<span></span>
</div>
</div>
Any idea how this can be solved? I need a HTML/CSS solution, I don't want to solve this with JS. I have tried a million things (CSS Grid, display: inline-block, all possible flex properties, ...) and different answers on SO, but nothing worked so far.