How to show multiline text in a table cell with CSS?

Spread the love

Sonetimes, we want to show multiline text in a table cell with CSS

In this article, we’ll look at how to show multiline text in a table cell with CSS.

How to show multiline text in a table cell with CSS?

To show multiline text in a table cell with CSS, we set the white-space and word-break properties.

For instance, we write

td {
  white-space: pre-line;
  word-break: break-all;
}

to set the white-space property to pre-line to show the line breaks.

Then we use word-break: break-all; to break long words into the next line.

Conclusion

To show multiline text in a table cell with CSS, we set the white-space and word-break properties.

Leave a Reply

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