How to prevent text from overflowing in CSS?

Spread the love

Sometimes, we want to prevent text from overflowing in CSS.

In this article, we’ll look at how to prevent text from overflowing in CSS.

How to prevent text from overflowing in CSS?

To prevent text from overflowing in CSS, we set the overflow property.

For instance, we write

<div id="myDiv">stuff</div>

to add a div.

Then we write

#myDiv {
  overflow: hidden;
}

to add overflow: hidden; to hide the overflowing text.

Conclusion

To prevent text from overflowing in CSS, we set the overflow property.

Leave a Reply

Your email address will not be published.