Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling HTML e-mail

When creating an HTML e-mail how do you specify the appearance, for example the font? Is there a better way than using inline CSS? I'm using cfmail to send e-mails.

like image 474
Celeritas Avatar asked May 29 '12 20:05

Celeritas


People also ask

How do you add a style to an email?

There are three ways to include styles within an email: using external stylesheets, embedded styles, or inline styles. While external stylesheets are a great option for web design, they aren't the best option for email design—many webmail clients block links to external stylesheets.

Can you add a style tag to email?

Yes you can. However you have to keep in mind that few email clients respect css standards. Just stick to basic css properties like margin and padding , etc., and it should all be fine. Also you can style your html elements inline ( <div style=""> ) though it's not an elegant solution.


2 Answers

You can style it in the <style> blocks in the head section, but the best/consistent way to style anything in HTML emails is by doing it inline unfortunately. If you're feeling lazy you can use http://premailer.dialect.ca/ to move everything inline for you.

like image 126
David Nguyen Avatar answered Oct 15 '22 12:10

David Nguyen


The most important aspect of html mails is making sure the recipient can read the mail. For this reason it is important to stick to basic HTML and than means inline CSS only i'm afraid.

I use this tool - http://inlinestyler.torchboxapps.com/
Source files - https://github.com/davecranwell/inline-styler

like image 40
Stephen Avatar answered Oct 15 '22 10:10

Stephen