So I taught myself to code.
Design
Code
Resources
May not work for everyone
A/B Test the hell out of your emails
There are a LOT of pre-made template options...
... which I didn't use.
Minimum Touchable Area
44px by 44px
44px by 44px
"Note: Prior to the creation of CSS, HTML <table> elements were often used as a method for page layout. This usage has been discouraged since HTML 4, and the <table> element should not be used for layout purposes."
"LOL"
No wrapper <table> makes code disappear in Apple Mail and Outlook 2011
do not display as inline or block
Default to display:table;
Chrome ignores max-width in that case
Set tables to display:block;
Gmail doesn't support <style> in <head>
Outlook.com doesn't support link in <head>
Many clients don't support a whole bevy of CSS!
You will, unfortunately, be doing a lot of this:
From: ${userName}
<${userEmail}>
<%--Wrapper Table Begin--%>
<%--Wrapper Table End--%>
Tables all the way down.
Always have alt=" " or a background color.
This is also great for accessibility!
It's on Github
Readability or Device Targetting
@media only screen and (min-device-width: 768px) and
(max-device-width: 1024px) {
.background-table {
max-width: 600px;
}
}
Note: media queries don't work on all clients.
Use in conjunction with fluid layouts (% based widths)
@media only screen and (max-width: 480px), (max-device-width: 480px) {
.background-table {
max-width: 480px;
}
}
"The device pixel ratio is the ratio between logical pixels and physical pixels."
From Stack Overflow
Target retina or high res devices
@media all and (min-device-pixel-ratio : 1.5),
all and (-webkit-min-device-pixel-ratio: 1.5) {
// Retina device styles go here!
}
When to use?
Sometimes inline styles overwrite media queries...
@media only screen and (max-width: 480px), (max-device-width: 480px) {
.headerBar {
height: 5px !important;
line-height: 5px !important;
}
}
Blah blah blah
Set a line-height on the surrounding <td>
Super weird and only occurs occasionally.
OR
Outlook 2007, 2010, 2013, and Outlook in IE disallow HTML/CSS image sizing.
@media all and (min-device-pixel-ratio : 1.5),
all and (-webkit-min-device-pixel-ratio: 1.5) {
td[class="cautionBar"] {
background-image: url('http://filenet.hotpads.com/images/email/warning.png');
background-position: center;
background-size: 30px 30px;
background-repeat: no-repeat;
width: 30px; !important;
height: 30px; !important;
}
td[class="cautionBar"] img {
display: none;
}
}
ignore max-width.
.background-table {
margin: 0;
padding: 0;
width: 100% !important;
line-height: 100% !important;
}
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
.background-table {
width: 600px;
}
}
Ignores <a> color styles in the <head>.
You have to style each and every <a> inline.
Outlook.com prefixes with .ExternalClass
AOL prefixes with .aolReplacedBody
Outlook.com: add the prefix yourself
AOL: .aolReplacedBody .aolReplacedBody (targets nothing).
Support class="★" but not id="★"
.★:not(#★){
/* AOL styles */
}
So do Android Mail and Outlook.com in IE
Targetting AOL only is probably not possible.
Strips overflow-x property
Strips !important
Strips display: none inline, but not in <style>
WebKit and Opera don't mask on border-radius
Positioned elements don't clip contents to border-radius.
Intermediate div removes the border-radius and overflow: hidden from css positioning.
.parent {
width: 300px;
height: 300px;
position: absolute;
}
.intermediate {
border-radius: 10px;
overflow: hidden;
}
.child {
width: 300px;
height: 300px;
}
Android Gmail enables forms prior to version 5.0.
Android Gmail disables forms as of version 5.0.
Android Email supports forms.