How to force table cell td content to wrap with CSS?

Spread the love

Sometimes, we want to force table cell td content to wrap with CSS.

In this article, we’ll look at how to force table cell td content to wrap with CSS.

How to force table cell td content to wrap with CSS?

To force table cell td content to wrap with CSS, we set the word-wrap property.

For instance, we write

td {
  overflow: hidden;
  max-width: 400px;
  word-wrap: break-word;
}

to set the max-width of the td element and add word-wrap: break-word; to make the content of the td wrap.

We add overflow: hidden; to hide any overflowing content.

Conclusion

To force table cell td content to wrap with CSS, we set the word-wrap property.

Leave a Reply

Your email address will not be published.