user3322300
user3322300

Reputation: 113

Word-wrap not working in LI element

I want to wrap the words automatically within width.

<ul class="dropdown-menu" style="width:298px;margin:15px 0 0 0;">
     <li>option 1 </li>
     <li>option 2 option 2 option 2 option 2 option 2 option 2</li>
</ul>

It's now working fine with white-space:normal

ul li{
     white-space:normal;
}

Upvotes: 10

Views: 32172

Answers (4)

Michael OConnor
Michael OConnor

Reputation: 51

This works well for me as it wraps correctly with or without whitespace:

li {
    word-break: break-all;
    }

Upvotes: 1

David M
David M

Reputation: 311

Add white-space:normal to your CSS element:

  word-break: normal;
  white-space: normal;

Upvotes: 6

Piyush Marvaniya
Piyush Marvaniya

Reputation: 2552

Please Try it...

ul li {
    word-break: break-all;
}

Upvotes: 17

Alex
Alex

Reputation: 457

use word-wrap:break-word; works perfectly fine for me here is the jsfiddle

Upvotes: -1

Related Questions