Hide text beyond div element


I have a fixed width DIV element that has some text that has no spaces for the HTML parser to automatically split into multiple lines. The text goes beyond the div and ruined the pgae:

  • Is there a way to make text go invisible?
  • Is it possible to split it into several lines or is it even better to split it into several lines using hypen at the end of each polyline?

Yours faithfully,
Rafid

+6
html
source share
3 answers

You can do this with CSS .

Is there a way to make text go invisible?

Yes: overflow

 #yourDivId { overflow: hidden; } 

Is it possible to split it into several lines

Yes: word-wrap

 #yourDivId { word-wrap: break-word; } 
+12
source share

You can use CSS:

 div { overflow: hidden; } 

Or:

 overflow: auto; 

More details: https://developer.mozilla.org/en/docs/Web/CSS/overflow

+1
source share

The answer to your first question is to use the following style:

 overflow: hidden; 

Also, if you want to be able to scroll through the div to see the content you can do

 overflow: auto; 

or

 overflow: scroll; 

To do what you ask in your second question, you will need javascript.

+1
source share

All Articles