By default, when text wraps, the width of the container becomes the max width. Instead, I want the width to fit the wrapped text.
div {
border: 1px solid red;
max-width: 100px;
display: inline-block;
}
<div>
qwertyuiop
</div>
<div>
qwertyuiop qwertyuiop
</div>
In the example above, I want the 2 boxes to have the same width. Is this possible without JS?
Re: duplicate of Make container shrink-to-fit child elements as they wrap: this has nothing to do with flexboxes
width: min-content
will force every word onto a new line. It will work for this specific example where you have only two words, but it will not work in a more general scenario where you have a paragraph of text. There is no pure CSS solution to this problem.