A content-sized label can hug short text while still needing a boundary for long text. Intrinsic sizing lets the content influence the box.
Worked example
<style>
.demo {
width: fit-content;
padding: 0.5rem 1rem;
}
</style>
<div class="demo">Width that follows content</div>Implementation notes
Long content can exceed a content-sized element even when the parent is fluid. Combine intrinsic sizing with a maximum and an appropriate word-breaking policy.
Try it yourself
Compare a short badge with an untranslated product identifier.
Open the CSS example →Editorial date November 3, 2025 · Published December 6, 2026