This is one of those tricky CSS things that I see come up every few months. I guess what better place to address it than CSS-Tricks eh?
The situation involves ragged-right inline text. Like when a paragraph of text breaks to the next line whenever the next word won't fit (i.e. most text on the internet). You want to add a background behind that text which:
- Follows the ragged-right edge
- Is padded along both the left and right edge of each line
What you can't do is simply apply a background and padding to, say, the
... read the whole story at css-tricks.com.
<p> element. Paragraphs are block-level, so the background will simply be a rectangle and not follow the ragged-right-ness.