Consider the following example:
.table {
width: 50px;
display: table;
padding: 10px;
border: 1px solid red;
}
.table a {
word-wrap: break-word;
}
.table2 a {
word-break: break-all;
}
<div class="table">
<a href="#">doNotClickMedoNotClickMedoNotClickMedoNotClickMe</a>
</div>
<div class="table table2">
<a href="#">doNotClickMedoNotClickMedoNotClickMedoNotClickMe</a>
</div>
As you can see in first table word-wrap
could not break the text to new line. But in second table word-break
could break the text. As far as I understand from mdn articles on word-wrap
and word-break
the only difference between them is that word-break
cause even chinese and japanese language text to break whereas word-wrap
doesn't work on those languages. Now how come that word-break
can break word in tables but word-wrap
not? Does html css spec mention this behavior?
Reading some other similar posts like this, this and this, another thing that I found unordinary is why does adding table-layout: fixed
to table allow word-wrap
to break words?