Skip to content

Instantly share code, notes, and snippets.

@elidickinson
Created May 6, 2013 15:10
Show Gist options
  • Save elidickinson/5525752 to your computer and use it in GitHub Desktop.
Save elidickinson/5525752 to your computer and use it in GitHub Desktop.
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
</td></tr></table>
</center>
<![endif]-->
@arturmamedov
Copy link

Isn't better use table and td?

@jonasgroendahl
Copy link

jonasgroendahl commented Apr 6, 2021

love it, thanks @elidickinson

still works after 8 years

@haoksam
Copy link

haoksam commented Jul 5, 2021

Great solutions everyone! Although none of them can stand the normal text mixed with super long words (or just text with no spaces). Windows Mail/Outlook (2007, 2010, 365) keep stretching the table...
NB: break-all and hyphens wouldn't help since the first will break normal words, and the later will brake the links.

@leGnacq
Copy link

leGnacq commented Oct 1, 2021

@philipp-klinz Great job this works perfectly to center object without center text.
If someone want to center object and text, simply use style="text-align:center;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment