You will need to add table-layout: fixed; to the table:

table {width:100%; table-layout: fixed;}
table td {word-wrap:break-word;}
<table>
   <thead>
      <tr>
         <th>very long word</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>ablkasd/123123123/agsdfasdf/asdfasdfasdf/_sdfsdfsdf{123123-14werwwer-14124124-wefweshtsdf-235232323}/3235235/dasasdfasdfasdf.bsfs</td>
      </tr>
   </tbody>
</table>

Answer from dfsq on Stack Overflow
🌐
GitHub
github.com › dompdf › dompdf › issues › 2248
Word break styling in a table cell does not work if text is not contained within another element with a defined width · Issue #2248 · dompdf/dompdf
September 24, 2020 - Word break styling in a table cell does not work if text is not contained within another element with a defined width#2248
Author   hmanprod
Discussions

css - Using "word-wrap: break-word" within a table - Stack Overflow
Fascinating problem, not seen it before. It seems though this topic a similar (the same?) question was asked: stackoverflow.com/questions/1258416/word-wrap-in-a-html-table ... There's lots of discussion on related issues here and elsewhere. There is definitely a lot of confusion around this issue and a lot of browser incompatibilities. ... More on stackoverflow.com
🌐 stackoverflow.com
Word break, break word... — DataTables forums
Break-word is working in this example, but i don't understand why? I made another fiddle with just a non-DataTables table: ... Table width: 100% Table layout: auto (default for table-layout) And again i put "word-break: break-word;" on the td's · In this case breaking the word is not working, ... More on datatables.net
🌐 datatables.net
word-wrap: break-word not working any longer
In version 0.8.6 the css property "word-wrap: break-word;" on table cells was working as expected (a word is split in a table column with a fixed width): In our tests with dompdf version ... More on github.com
🌐 github.com
9
May 6, 2022
"overflow-wrap: break-word" not working in table
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 ... ... More on github.com
🌐 github.com
8
November 16, 2017
Top answer
1 of 2
3

You can make the words (long strings) break with word-break: break-word; in addition to your word-wrap like this:

h2 {
  word-wrap: break-word;
  word-break: break-word;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container-fluid">
  <div class="panel panel-default">
    <div class="panel-heading">test </div>
    <div class="panel-body">
      <table class="table">
        <thead>
          <tr>
            <th></th>
            <th>Name</th>
            <th>Sex</th>
            <th></th>
          </tr> 
        </thead>  
        <tbody>     
          <tr >   
            <td>ff</td>
            <td>wer</td>
            <td>1</td>
            <td>asdf</td>
          </tr>     
          <tr class="">
            <td colspan="4">
              <div class="container-fluid">
                <div class="row">
                  <div class="col-lg-6 col-md-6 col-xs-12"><h2>11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</h2>
                  </div>
                  <div class="col-lg-6 col-md-6 col-xs-12"><h2>22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222</h2>
                    <hr>
                  </div>
                </div>
                <div class="row"><h2>33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333</h2>
                </div>
              </div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

This will also work on other elements like divs, spans etc.

What's the difference between word-wrap and word-break?

word-wrap: The word-wrap CSS property is used to specify whether or not the browser may break lines within words in order to prevent overflow when an otherwise unbreakable string is too long to fit in its containing box.

word-break: The word-break CSS property is used to specify how (or if) to break lines within words

In conclusion you need them both to break long strings without any spaces where the word-wrap could take in place.

2 of 2
0

Use table-layout:fixed this will wrap the table within the width of the parent div and text will break automatically.

table{
  table-layout:fixed;
}
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>

    <div class="container-fluid">
      <div class="panel panel-default">
        <div class="panel-heading">test </div>
        <div class="panel-body">
          <table class="table">
            <thead>
              <tr>
                <th></th>
                <th>Name</th>
                <th>Sex</th>
                <th></th>
              </tr> 
            </thead>  
            <tbody>     
              <tr >   
                <td>ff</td>
                <td>wer</td>
                <td>1</td>
                <td>asdf</td>
              </tr>     
              <tr class="">
                <td colspan="4">
                  <div class="container-fluid">
                    <div class="row">
                      <div class="col-lg-6 col-md-6 col-xs-12">                    <h2 style="word-wrap: break-word">11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</h2>
                      </div>
                      <div class="col-lg-6 col-md-6 col-xs-12">                    <h2 style="word-wrap: break-word">22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222</h2>
                        <hr>
                      </div>
                    </div>
                    <div class="row">                  <h2 style="word-wrap: break-word">33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333</h2>
                    </div>
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>

🌐
DataTables
datatables.net › forums › discussion › 34029 › word-break-break-word
Word break, break word... — DataTables forums
So the only way to break words in tables with html / css and (without wrappers or something) is to use "table-layout: fixed;". But that in combination with "width: auto" is also not working...even if you put a width on the "table cell" where you want to use: "word-wrap: break-word;".
🌐
Mozilla Bugzilla
bugzilla.mozilla.org › show_bug.cgi
587438 - word-wrap:break-word does not work in tables
August 13, 2022 - Not aware of any other browser with this issue. I just tested in Chromium 49 and today's Firefox nightly, and both now render the testcase on this bug similarly (for both the given test, and when table-layout:fixed is used on the table). According to a similar bug report on Chromium's end, this is intentional, and they expect authors to use table-layout:fixed to get break-word working in table cells: https://bugs.chromium.org/p/chromium/issues/detail?id=155767 In light of this, I suspect this is a WONTFIX.
Find elsewhere
🌐
GitHub
github.com › dompdf › dompdf › issues › 2868
word-wrap: break-word not working any longer · Issue #2868 · dompdf/dompdf
May 6, 2022 - In version 0.8.6 the css property "word-wrap: break-word;" on table cells was working as expected (a word is split in a table column with a fixed width): In our tests with dompdf version ...
Author   PDFCoder
🌐
ItSolutionstuff
itsolutionstuff.com › post › word-wrap-break-word-not-working-tableexample.html
word wrap break word not working table - ItSolutionstuff.com
September 5, 2020 - If you try with tr or td tag to give word-wrap: break-word style css then it will not affect. When i was try to give word wrap css on my td tag it was not working same as for i did try with span tag but same result.
🌐
GitHub
github.com › Kozea › WeasyPrint › issues › 541
"overflow-wrap: break-word" not working in table · Issue #541 · Kozea/WeasyPrint
November 16, 2017 - 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; }
Author   kination
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › word-break
word-break - CSS - MDN Web Docs
To prevent overflow, word breaks should be inserted between any two characters (excluding Chinese/Japanese/Korean text). ... Word breaks should not be used for Chinese/Japanese/Korean (CJK) text.
🌐
Salesforce
trailhead.salesforce.com › trailblazer-community › feed › 0D54V00007T4B3USAV
Wordwrap is not working in table in Visualforce PDF - Trailhead
Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era.
🌐
W3Docs
w3docs.com › css
How to Wrap the Content of a Table Cell
August 13, 2022 - Use the border-collapse property set to "collapse" and table-layout property set to "fixed" on the <table> element. Also, specify the width of the table. Then, set the word-wrap property to its "break-word" value for <td> elements and add border ...
🌐
Stack Overflow
stackoverflow.com › questions › 64657197 › horizontal-scroll-not-working-after-using-word-break-in-td-of-table
html - horizontal scroll not working after using word-break in td of table - Stack Overflow
October 30, 2025 - The only td that requires you to have a scroll bar you have instructed to break the word instead. Many of your td's also have a MAX-width property. That means that your td will take up to 100px, but it can be less. Hence, none of those td's will force a scroll bar to appear either. The data you pose fits within the constraints of your screen width. For example, this code will show a scroll bar because a td that does not have the word break styling is not present, and it forces the entire tr width to push past the screen width.
🌐
Lightrun
lightrun.com › answers › kozea-weasyprint-overflow-wrap-break-word-not-working-in-table
"overflow-wrap: break-word" not working in table
<table style="overflow-wrap: break-word; width: 100px; table-layout: fixed"> <tr> <td> TD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioencTD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioencTD2lsneinocnosneonocnsoneoincosneoicnosneocnsoinoiesnioenc </td> </tr> </table> ... Tables as always: special beasts. Indeed, table-layout: fixed does the trick with all of my Pangos. Read more comments on GitHub > 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 ...