How do I get a text element, for example <p>
to dynamically be exactly the same width as the text? If the text is forced to new rows by a parent or the document width.
You can see the problem illustrated here:
.wrapper {
background-color:#ff0000;
padding:10px;
width:530px;
}
p {
background-color:#00ff00;
display:inline-block;
width:auto;
}
<div class="wrapper">
<p>This sentance wants to be alone on it's row.</p>
<p>Now we want this element to be as narrow as possible. Removing this space: before-this-word.</p>
</div>
I have tried to find answers for this, but can't find any.