div css
There is a line of text in my div, which is long or short. I want the div to adapt its length and width according to the text.Using CSS float attribute or absolute positioning can make the size of DIV adapt to the size of the content, but it will bring other problems
Set display: inline
Just don’t set the width and height attributes.
Set display: inline. This is the correct answer.