[CSS] Forced line break

aKuma59 Posted messages 105 Status Member -  
zigoss Posted messages 3 Status Member -
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 answers

  1. GreenDay-punkweapon Posted messages 82 Registration date   Status Member 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
    1. Trebly3 Posted messages 4 Status Member 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
    2. Nolwenn
       
      Thank you!!! It was a long time ago but it’s still useful :)
      0