Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML email align text

I am trying to align a part of text to the right and the other part to the left in an HTML mail but in Outlook the float doesn't work. So basically I am looking for float CSS in Outlook. I know it sounds pretty creepy and text-align or align="" didn't work. Any suggestions?

<td>
   <span style="text-align:left; float:left;">
       First part
   </span>
   <span style="text-align:right; float:right;">
       Second part
   </span>
</td>
like image 468
user1299846 Avatar asked Apr 03 '12 08:04

user1299846


People also ask

How do I align my text in HTML?

We can change the alignment of the text using the text-align property. We can align the text in the center, Left, Right. The text alignment can be done with CSS(Cascading Style Sheets) and HTML Attribute tag. Note: The left alignment of the text is default.


2 Answers

Honestly, if you're doing an HTML email I'd stick to using tables. Not all CSS selectors are available in all email clients and you'll drive yourself mad trying to do it any other way. HTML emails are like the web 5 years ago.

There are a couple of good documents on the subject:

https://www.campaignmonitor.com/css/

http://www.emailology.org/

For your example:

<td>
  <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td align="left">First part</td>
      <td align="right">Second part</td>
    </tr>
  </table>
</td>

It's horrible but unfortunately it's still the best way.

like image 114
SpaceBeers Avatar answered Sep 19 '22 15:09

SpaceBeers


Use (shudder) layout tables.

Outlook's support for styling of email is so awful that there isn't any other way.

There is a 24 ways article with some general advice for writing HTML formatted email.

like image 28
Quentin Avatar answered Sep 20 '22 15:09

Quentin