I\'ve been using word-wrap: break-word
to wrap text in div
s and span
s. However, it doesn\'t seem to work in table cells. I have a tabl
https://jsfiddle.net/krf0v6pw/
HTML
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
CSS
.content{
word-wrap:break-word; /*old browsers*/
overflow-wrap:break-word;
}
table{
width:100%; /*must be set (to any value)*/
}
.overflow-wrap-hack{
max-width:1px;
}
Benefits:
word-break:break-all
. Which is better because it tries to break on spaces first, and cuts the word off only if the word is bigger than it's container.table-layout:fixed
needed. Use your regular auto-sizing.width
or fixed max-width
in pixels. Define %
of the parent if needed.Tested in FF57, Chrome62, IE11, Safari11