1

I am working with content management and there is issue created with line break. I am displaying some content and it not gets break in multiple lines automatically. So I used CSS property "word-wrap:break-word".

When I used it, line gets braked but it cutting words of end of line.

I want to break only line and not a word.

Is there any solution ?

HTML

<div class="profile_fields">
 <ul>
  <li>
    <span id="CE_profile">Description:</span>
    <span>Join us in this 90 minute presentation and learn the indications and 
          "how to" for practical topics that will improve your diagnostic and
           treatment skills with cats. 
    </span> 
  </li>
 </ul>
</div>

CSS

.profile_fields {
    margin-top: 10px;
    overflow: hidden;
}
.profile_fields > ul {
    padding: 10px;
}
.profile_fields > ul > li > span + span {
    width: 330px !important;
    word-wrap: break-word;
}
.profile_fields > ul > li > span + span {
    display: block;
    float: none;
    min-width: 0;
    overflow: hidden;
    width: 380px;
}

I want to break content of second span in multiple lines

Fiddle: http://jsfiddle.net/fpTwP/

10
  • 2
    It is supposed to be the natural behavior of elements. Can you show us your HTML and CSS?
    – Itay
    Commented Sep 16, 2013 at 13:18
  • Nothing can be suggested without seeing the actual code.
    – Arpit
    Commented Sep 16, 2013 at 13:19
  • Html is <li> <span id="CE_profile">Description:</span> <span>Join us in this 90 minute presentation and learn the indications and "how to" for practical topics that will improve your diagnostic and treatment skills with cats. </span> </li> CSS is .profile_fields > ul > li > span + span { width: 330px !important; word-wrap: break-word; } .profile_fields > ul > li > span + span { display: block; float: none; min-width: 0; overflow: hidden; width: 380px; } Commented Sep 16, 2013 at 13:35
  • I want to break content of second span in multiple lines. Commented Sep 16, 2013 at 13:36
  • Always edit your question instead of posting details in comments. And your CSS doesn't respect your HTML (.profile_fields is not there) Commented Sep 16, 2013 at 13:46

1 Answer 1

2

try this:

   word-break: keep-all;

more info on word breaking in css can be found here: http://docs.webplatform.org/wiki/css/properties/word-break

3
  • 2
    Consider docs.webplatform.org/wiki/css/properties/word-break as an alternative link
    – asfallows
    Commented Sep 16, 2013 at 13:25
  • i don't realy get why you want to boycot -w3schools, but anyways i changed my link Commented Sep 16, 2013 at 13:29
  • @jonasvermeulen they used to be full of inaccuracies - they got better - but there are still parts that are wrong or at least explained the wrong way. So it is often better to suggest another better source then w3schools, especially when learning there is the risk of learning bad styles. E.g. the page JavaScript How To, while the infos are not wrong they are bad explained.
    – t.niese
    Commented Sep 16, 2013 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.