[CSS] Forced line break

aKuma59 Posted messages 105 Status Membre -  
zigoss Posted messages 3 Status Membre -
Good evening,

Do you know how to force a line break in a text inside a div? I have a div with a max-width of 510px, but if I enter a super long word, it overflows the div, and I would like to force a line break in this case. Is it possible to do this in CSS or do I need to use a script?

Thank you in advance :)
Configuration: Windows XP Safari 525.19

15 réponses

GreenDay-punkweapon Posted messages 82 Registration date   Status Membre 58
 
I found this property (but I can't quite get it to work). Try it and let me know if it works

white-space
normal: line breaks are automatic (default)
nowrap: no automatic line breaks, unless an xHTML tag like <br /> is present.
pre: line breaks are made as the text was entered in the source code (like the xHTML tag <pre>)
43
Trebly3 Posted messages 4 Status Membre 1
 
Good evening, I happen to read this message quite late, but sometimes problems remain without a good solution for a long time.

When the text becomes long in certain translations (Russian for example), word hyphenation is often necessary.
In this case, if one wants to be very neat, one develops a template that takes into account languages by language group with a CSS for each group.

Here, the appropriate parameter is "word-wrap:break-word;"

As for "white-space", it allows the text to fold by generating line breaks when spaces appear;
Obviously, if the word is longer than the line, it goes off the screen.

See you later!
1
Nolwenn
 
Thank you!!! It was a long time ago but it’s still useful :)
0