Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break long words in html email in outlook 2010

I'm taking end user input and inserting it into an HTML email. But if the end user enters a long URL or really long word, it breaks my HTML layout in Outlook 2010 by extending the column or div beyond the width specified.

In Chrome, Firefox, IE7+, and Safari, I can use style="table-layout:fixed" in order to force the table columns to certain widths. But Outlook 2010 ignores this, and the long word pushes the table width out beyond the fixed width.

With Divs, In Chrome, Firefox, IE7+, and Safari, I can use style="word-wrap:break-word; overflow:hidden; width:100px", to fix the div width. But in Outlook 2010, it pushes the div out beyond the fixed width.

How can I get outlook2010 to wrap the long word, and honor the fixed width?

Here is my sample HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<table width="400" style="table-layout: fixed" border="1">
    <tr>
        <td width="100">
            yo
        </td>
        <td width="300">
            Don't move me
        </td>
    </tr>
</table>
<table width="400" style="table-layout: fixed" border="1">
    <tr>
        <td width="100" style="word-wrap: break-word; overflow: hidden; width: 100px" border="1">
            yoooooooooooooooooooooooooooooooooooooooooooooooooooooo
        </td>
        <td width="300">
            Ya moved me
        </td>
    </tr>
</table>
<table width="400" border="1">
    <tr>
        <td width="100">
            <div style="word-wrap: break-word; overflow: hidden; width: 100px" border="1">
                yoooooooooooooooooooooooooooooooooooooooooooooooooooooo
            </div>
        </td>
        <td width="300">
            Ya moved me
        </td>
    </tr>
</table>
</body>
</html>
like image 946
Hoppe Avatar asked Apr 10 '12 20:04

Hoppe


People also ask

How do you break a long word in HTML?

Use word-wrap:break-word; It even works in IE6, which is a pleasant surprise. word-wrap: break-word has been replaced with overflow-wrap: break-word; which works in every modern browser.

How do I send an HTML email in Outlook 2010?

In Internet Explorer, browse to the HTML page that you saved as a file. Then, choose File | Send | Page by Email.

What is text wrapping in Outlook?

When you wrap long lines of text, the Outlook email client automatically breaks sentences away from the current line to start on a new line. This shortens the length of all outgoing emails and is similar to narrowing the margins of the writing space. Open Outlook and go to the File menu. Select Options.


2 Answers

Use the Microsoft proprietary word-break:break-all;

  <td style="word-break:break-all;"> 
like image 109
samanthasquared Avatar answered Oct 21 '22 04:10

samanthasquared


I know I'm late to the party, but the recommendation I can make for others that bump into this post and want to use the property word-break:break-all; is to wrap the word you need to break in an element inside the <td> and then apply word-break:break-all;.

Like so:

<td>Serial #: <a href="#" style="word-break:break-all;">1111222233334444555566667777888899990000</a></td>

On this note you can also use other things to break long words like the <wbr> element, or the "zero-width space character" a.k.a. ZWSP which is &#8203;, and if you want hyphens when the text breaks, use the &shy;.

Check this (for now ugly ><) demo I made in CodePen: Word-breaks in long string words.

More info in the following links:

  • The wbr tag - QuirksMode.org
  • <wbr> - MDN - Mozilla Developer Network
  • wbr (HTML element) - SitePoint.com

Hope this helps.

like image 27
Ricardo Zea Avatar answered Oct 21 '22 02:10

Ricardo Zea