How to wrap text in a td tag with CSS?

Spread the love

Sometimes, we want to wrap text in a td tag with CSS.

In this article, we’ll look at how to wrap text in a td tag with CSS.

How to wrap text in a td tag with CSS?

To wrap text in a td tag with CSS, we make the table layout fixed and use the word-wrap property.

For instance, we write

table {
  table-layout: fixed;
}

td {
  word-wrap: break-word;
}

to add table-layout: fixed; to make table layout fixed.

And then we add word-wrap: break-word; to wrap the td’s content.

Conclusion

To wrap text in a td tag with CSS, we make the table layout fixed and use the word-wrap property.

Leave a Reply

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