[CSS] Forced line break
aKuma59
Posted messages
105
Status
Membre
-
zigoss Posted messages 3 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 :)
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
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>)
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>)
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!