Users can enter text in a particular form of mine and I want to display that text in a table format. But sometimes users enter really long lines without spaces. So the text forces the table to be too wide.
I can limit the td
element to have a max-width
, but then the text keeps flowing over other cells. I can then set overflow: hidden
and the text just gets cut off:
But I need to be able to read it all. Is there a way to wrap a long line of text in a table even if the text doesn't have spaces?
Creating Line BreaksThe <br> tag is used to insert a line break on the web page. Since the <br> is an empty element, so there is no need of corresponding </br> tag.
Definition and Usage. The word-wrap property allows long words to be able to be broken and wrap onto the next line. Show demo ❯ Default value: normal.
Try adding this to your CSS file on the element that requires it:
word-wrap:break-word;
Here it is in action:
Working example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With