Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a long line of characters wrap in HTML [duplicate]

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: enter image description here

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?

like image 811
at. Avatar asked Aug 10 '13 02:08

at.


People also ask

How do I make two lines of text in HTML?

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.

What is line wrap in HTML?

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.


1 Answers

Try adding this to your CSS file on the element that requires it:

word-wrap:break-word;

Here it is in action:

Working example

like image 127
Sir Avatar answered Sep 24 '22 03:09

Sir