Is there a way to apply a background color around text that dynamically adjusts in size based on the length of the text?
If you are unable or prefer not to wrap the text in its own inline element for applying a background, your options are limited.
The only method I can think of to add a background color specifically to the text itself is by using `text-shadow` with multiple shadows.
Check out this JSfiddle Demo
.multiline
{
padding:0px;
white-space: pre-wrap;
height: 100px;
width: ;
margin:0px;
text-shadow:
0 0 1px green,
0 0 2px green,
0 0 3px green,
0 0 4px green,
0 0 5px green,
0 0 6px green,
0 0 7px green,
0 0 8px green,
0 0 9px green;
}
<div style="background-color:#FFD382;" align="left" class="multiline">
Peter
How are you
2016-8-10
</div>