gpt-4o-2024-08-06· OpenAI
WildChat-4.8M (AI2)
make dark mode and responsive email template for all resolutions. use em instead of px.
- User
make dark mode and responsive email template for all resolutions. use em instead of px.
- Assistant
make dark mode and responsive email template for all resolutions. use em instead of px.
Creating a responsive, dark mode-friendly email template using em units is a great way to ensure compatibility across different devices and encourage accessibility.
Below is a basic HTML/CSS template for an email that uses em units and includes styling for dark mode. Take into account that not all email clients support media queries or dark mode adjustments in the same way, but this should work well in most modern clients.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
/* Basic Reset */
body, table, td, a {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%; /* Prevent winphone text size adjust */
}
table, td {
mso-table-lspace: 0pt;
mso-table-rspace: 0pt; /* Removes spacing between tables in Outlook 2007 and up */
}
img {
-ms-interpolation-mode: bicubic; /* Better rendering in IE */
border: 0;
height: auto;
line-height: 100%;
outline: none;
text-decoration: none;
}
/* Responsive Styles */
body {
height: 100% !important;
margin: 0 !important;
padding: 0 !important;
width: 100% !important;
}
.email-container {
max-width: 30em;
margin: auto;
width: 100%;
}
/* Dark Mode Styles */
@media (prefers-color-scheme: dark) {
body {
background-color: #121212;
color: #e0e0e0;
}
.container {
background-color: #1e1e1e;
}
a {
color: #bb86fc;
}
}
/* General Styles */
.container {
background-color: #ffffff;
padding: 2em;
border-radius: 0.5em;
}
h1 {
font-size: 2em;
margin-bottom: 0.5em;
}
p {
font-size: 1em;
line-height: 1.5em;
}
a {
color: #1d4ed8;
text-decoration: none;
}
@media screen and (max-width: 600px) {
h1 {
font-size: 1.5em;
}
p {
font-size: 0.9em;
}
}
</style>
</head>
<body style="margin: 0; padding: 0; background-color: #ffffff;">
<table role="presentation" width="100%">
<tr>
<td style="padding: 1em;">
<div class="email-container">
<div class="container">
<h1>Welcome to Our Service!</h1>
<p>Thank you for choosing us. We are committed to providing you with the best service possible.</p>
<p>If you have any questions, feel free to <a href="mailto:support@example.com">contact us</a>.</p>
</div>
</div>
</td>
</tr>
</table>
</body>
</html>
Responsive Design:
max-width with percentages and em units to ensure it scales on all devices.Dark Mode:
@media (prefers-color-scheme: dark) media query to adjust background and text colors for dark mode.Use of em:
em unit is used for padding, font-sizes, and spacing to make the content adaptable to the user's default font size settings.Remember to test your email template across different email clients and devices, as there can be considerable variance in how HTML/CSS is rendered.