Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to center your HTML email content in the browser window (or email client preview pane)?

I normally use CSS rules for margin:0 auto along with a 960 container for my standard browser based content, but I'm new to HTML email creation and I've got the following design that I'd like to now center in the browser window without standard CSS.

http://static.helpcurenow.org/mockups/emails/2010/may-survey/survey.html

I seem to recall seeing somewhere that it can also be accomplished by wrapping your email table design in an outer table set to width:100% and using some inline style for text-align:center on the tbody or something like this to do it?

Is there a best practice for this?

like image 768
Joel Glovier Avatar asked May 18 '10 13:05

Joel Glovier


People also ask

How do you center an HTML email?

Try the following: Wrap your content in another table with style="table-layout: fixed;" and align=“center”. Why use a table for this if there's only going to be one row and one column?

How do I center my content in HTML?

To center text using HTML, you can use the <center> tag or use a CSS property.

How do I center my screen in HTML?

You can do this by setting the display property to "flex." Then define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.


1 Answers

Align the table to center.

<table width="100%" border="0" cellspacing="0" cellpadding="0">     <tr>         <td align="center">             Your Content         </td>     </tr> </table> 

Where you have "your content" if it is a table, set it to the desired width and you will have centred content.

like image 100
Shadi Almosri Avatar answered Oct 19 '22 11:10

Shadi Almosri