I feel like I'm losing my mind...
span {
  max-width: 150px;
  display: inline-block;
  background: yellow
}<span>words words words words words words words words </span>What I want: The yellow box to be no wider than the longest line of text.
What I get: Lots of empty space on the right hand side.
A few years ago I could have believed this was a limitation of CSS. But it's 2023, things are supposed to be good these days...
I've tried everything I can think of, floats, tables, flex, grid, obscure property values like fit-content etc.
I THINK I'm coming to the conclusion that this isn't possible without javascript?
Can someone confirm? Can someone explain WHY?
Or am I missing something simple?
Thank you!
 
     
    