How to prevent the DIV from starting a new line with CSS?

Spread the love

To prevent the DIV from starting a new line with CSS, we set the overflow and white-space properties.

For instance, we write

<div style="overflow: hidden; white-space: nowrap">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus mauris
  nunc, vehicula at nisl eu, aliquam ultrices augue. Nullam eget auctor metus.
</div>

to add a div that hides overflowing text with overflow: hidden

And we hide any text that wraps to the next line with white-space: nowrap.

Leave a Reply

Your email address will not be published. Required fields are marked *