JSFiddle - React, Tailwind, and code Playground
HTML
<p>
<span>Lorem ipsum dolor sit ame. Lorem ipsum dolor sit ame. Lorem ipsum dolor sit ame. Lorem ipsum dolor sit ame. Lorem ipsum dolor sit ame. Lorem ipsum dolor sit ame. </span>
</p>
<p>
<span>Although this solution also requires some "math", it still seems better than previous solution just because it doesn't use transform, which only works on blocks, and background and foreground color align properly, so we avoid having to use overflow: hidden. Credit to CBroe and Essam Al-Mansouri from Stackoverflow.com </span>
</p>
CSS
body { margin: 0; }
p {
padding: 0; margin: 16px; line-height:40px; font-size:24px; background-color: lightblue;
}
p span { background:rgba(0, 0, 0, 0.1); padding-top: 16px; bottom: -8px; position: relative;}