question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"overflow-wrap: break-word" not working in table

See original GitHub issue

I’m implementing table inside html, but line break seems not working in items in table. This is CSS

table {
  ...
  td, th {
    padding: 5px 15px 5px 15px;
    word-break: break-all;
    white-space:nowrap;
  }

and HTML

...
<div class="item-box">
            <table>
...
                <tr>
                <td>TD1</td>
                <td>
TD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioencTD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioencTD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioenc</td>
                <td>TD3</td>
                </tr>
...

and it shows like this. screen shot 2017-11-16 at 20 42 03

Is there something I’m doing wrong?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
liZecommented, Jan 3, 2019

You’ll need to use table-layout: fixed. Automatic table layout always gives cells at least the minimum size of their content without taking care of overflow-wrap:break-word or hyphenation (and I think that it’s a good idea, even if it’s strange in this case). Other browsers (at least Chrome and Epiphany) give the same rendering as WeasyPrint.

<table style="overflow-wrap: break-word; width: 100px; table-layout: fixed">
  <tr>
    <td>
TD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioencTD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioencTD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioenc
    </td>
  </tr>
</table>
0reactions
Tontynacommented, Jan 5, 2019

Tables as always: special beasts. Indeed, table-layout: fixed does the trick with all of my Pangos.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using "word-wrap: break-word" within a table - Stack Overflow
That is, the table stops narrowing after step 2 and step 3 doesn't ever happen. The break-word doesn't seem to be filtering down....
Read more >
Word break styling in a table cell does not work if text ... - GitHub
Word break styling in a table cell does not work if text is not contained within ... tried using also "overflow-wrap: anywhere" to...
Read more >
How to break long words in an HTML (or CSS) table
word -wrap prevents a long word from overflowing its container by breaking the text onto the next line. It works fine when applied...
Read more >
wrap, overflow - wrap - , and - word - break - LogRocket Blog
To get the table to fit within its container and overflow-wrap to work, set the value of the table-layout property to fixed and...
Read more >
overflow-wrap - CSS: Cascading Style Sheets - MDN Web Docs
Note: In contrast to word-break , overflow-wrap will only create a break if an entire word cannot be placed on its own line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found