css make width fit content if parent element is smaller code example Example: make div the size of the text inside div { display: inline-block; }