cheatsheets/html-email.md

66 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2017-08-29 15:35:17 +00:00
---
title: HTML emails
category: HTML
2020-07-04 13:33:09 +00:00
updated: 2017-08-30
2017-08-29 15:35:17 +00:00
---
### Properties to avoid
| Property | Where |
| --- | --- |
| `position` | (Outlook, Gmail, Yahoo) |
| `display` | (Outlook, Gmail) |
| `float` | (Outlook) |
| --- | --- |
| `height` | (Outlook) |
| `width` _in p/div_ | (Outlook) |
| `padding` _in p/div_ | (Outlook) |
| `background` | (Outlook, Gmail) |
| `min-width` | (Outlook) |
| `max-width` | (Outlook) |
| --- | --- |
| `opacity` | (Outlook, Gmail, Yahoo) |
| `box-shadow` | (Outlook, Gmail, Yahoo) |
| --- | --- |
| `rgba()` | (Outlook) |
| `data-uri` | (all webmail) |
### Selectors to avoid
| `E[attr]` | (Outlook, Gmail) |
| `E:nth-child(n)` | (Outlook, Gmail) |
| `::before` _and_ `::after` | (Outlook, Yahoo, Gmail) |
2017-08-30 06:44:36 +00:00
| `E F` | (Gmail) |
| `E + F`, `E > F` _etc_ | (Outlook, Gmail) |
2017-08-29 15:35:17 +00:00
Inline your CSS as much as possible.
### Basic layout
```html
<table cellpadding="0" cellspacing="0" role="presentation">
2017-08-29 15:35:17 +00:00
<tr>
<td width="auto"></td>
<td width="600" background="#ffffff">
···
</td>
<td width="auto"></td>
</tr>
</table>
```
### Responsive
```html
<style>
@media only screen and (max-device-width: 480px)
</style>
```
`<style>` is supported in the head and body by everything except Gmail. Only use them for responsive styles.
## References
{: .-one-column}
- [CSS support matrix](https://www.campaignmonitor.com/css/) _campaignmonitor.com_