Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Word-wrap: break-word does not work with a very long word combined with width: 100%

Tags:

html

css

Why is it in this fiddle https://jsfiddle.net/0h1wbju0/ my word-wrap: break word and width: 100% aren't being respected and the long word is not being broken up into multiple lines to fit inside it's parent div? Thanks!.

HTML:

    <div class="first_div">
        <fieldset class="fieldset_description"><label>Description</label>
            <div data-id="description"> fdsjalllffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff</div>
        </fieldset>
    </div>

CSS:

.first_div {
  width: 200px;
}

.fieldset_description {
  max-width: 100%;
  word-wrap: break-word;
}

.description {
  max-width: 100%;
  word-wrap: break-word;
}
like image 950
Bryan Avatar asked Oct 19 '25 22:10

Bryan


1 Answers

you should use =>

`word-break: break-all;`

Working code jsfiddle

like image 110
Bandi Avatar answered Oct 22 '25 11:10

Bandi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!