Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox breaks word from slash

Why Firefox is breaking word from / (slash) and - (hyphen) into lines.

Example with / and -

table {
  width: 100%;
}
<table>
  <tbody>
    <tr>
      <td>
        LoremipsumdolorsitametconsecteturadipisicingelitLaboredistinctionamdoloresmodiamet/etblanditiisarchitectsundolorem/qnullobcaecatnobilibermollitia/sialiquiodiomagncommodi.

      </td>
    </tr>
  </tbody>
</table>

Example without / and -

table {
  width: 100%;
}
<table>
  <tbody>
    <tr>
      <td>
        LoremipsumdolorsitametconsecteturadipisicingelitLaboredistinctionamdoloresmodiametetblanditiisarchitectsundoloremqnullobcaecatnobilibermollitiasialiquiodiomagncommodi.
      </td>
    </tr>
  </tbody>
</table>

Both Examples are working good in other browsers, I have tried overflow-wrap but didn't work.

I'm using Firefox 67.0 (64-bit).

Please open it in Firefox.

like image 556
Abhishek Pandey Avatar asked May 29 '19 13:05

Abhishek Pandey


1 Answers

Looks as Mozilla is considering / and - as whitespace delimiters. After a small research I suggest escaping / and - with its html equivalent code, before emitting it to the table.

UPDATE
Found another pure CSS solution that works in mozilla too

table {
  width: 100%;
}

table td { 
    word-break: keep-all; 
}
<table>
  <tbody>
    <tr>
      <td>
        LoremipsumdolorsitametconsecteturadipisicingelitLaboredistinctionamdoloresmodiamet/etblanditiisarchitectsundolorem/qnullobcaecatnobilibermollitia/sialiquiodiomagncommodi.

      </td>
    </tr>
  </tbody>
</table>

Here is a small JS Snippet that escapes / and - to its equivalent html code.

var str = 'Loremipsumdolorsitametconsectetura-dipisicingelitLaboredistinctionamdol-oresmodiamet/etblanditiisarchitectsundolorem/qnullobcaecatnobilibermollitia/sialiquiodiomagncommodi.';

const escaped = str.replace(/\//g, '&#47;').replace(/-/g, '&#45;');
like image 149
Pankaj Prakash Avatar answered Oct 31 '22 12:10

Pankaj Prakash