Utveckling av HTML-e-post kraever defensiva, tabellbaserade layouter foer att renderas tillfoerlitligt i olika e-postklienter.
Klientbegraensningar och icke-tillaaten CSS
Egenskaper att undvika
| Egenskap och omfaang | Problematiska klienter | Saekert alternativ |
|---|---|---|
width pa p eller div |
Microsoft Outlook | Ange width pa td-element |
padding pa p eller div |
Microsoft Outlook | Tillaempa padding pa td-celler |
margin (alla former) |
Outlook, Hotmail | Anvaend tabellceller foer mellanrum |
background-image |
Outlook Windows desktop | Anvaend Microsoft VML-taggar |
data-uri-bilder |
Webmail clients | Vaerdsaett bilder pa externt HTTPS-CDN |
Selektorer att undvika
| Selektortyp | Problematiska klienter |
|---|---|
| Pseudoelement (::before, ::after) | Outlook, Yahoo, Gmail |
| Naerliggande selektorer (E + F, E > F) | Outlook, Gmail App |
| Attributselektorer ([href^="https"]) | Aeldre webbmejlklienter |
Tumregel: tillaempa alltid all CSS inline i style="..."-attribut pa td-tabellceller.
Grundlaeggande Responsiv E-postmall
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Responsive Email</title>
<style type="text/css">
@media only screen and (max-width: 600px) {
.container { width: 100% !important; }
}
</style>
</head>
<body style="margin: 0; padding: 0;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" style="padding: 20px 0;">
<table class="container" border="0" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse;">
<tr>
<td style="color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 24px;">
E-postens innehaall placeras haer.
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>