Responsive mailer html code
Here is an example of responsive HTML code for a mailer:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Mailer</title>
<style>
/* Global Styles */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
/* Responsive Styles */
@media only screen and (max-width: 600px) {
/* Mobile Styles */
.container {
width: 100%!important;
}
.header {
font-size: 18px!important;
}
.content {
font-size: 14px!important;
}
.button {
font-size: 12px!important;
padding: 10px 20px!important;
}
}
@media only screen and (min-width: 601px) and (max-width: 800px) {
/* Tablet Styles */
.container {
width: 80%!important;
}
.header {
font-size: 20px!important;
}
.content {
font-size: 16px!important;
}
.button {
font-size: 14px!important;
padding: 15px 30px!important;
}
}
@media only screen and (min-width: 801px) {
/* Desktop Styles */
.container {
width: 70%!important;
}
.header {
font-size: 24px!important;
}
.content {
font-size: 18px!important;
}
.button {
font-size: 16px!important;
padding: 20px 40px!important;
}
}
</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="600" class="container">
<tr>
<td align="center" valign="top">
<h1 class="header">Responsive Mailer</h1>
</td>
</tr>
<tr>
<td align="center" valign="top">
<p class="content">This is a responsive mailer example. It will adapt to different screen sizes and devices.</p>
</td>
</tr>
<tr>
<td align="center" valign="top">
<a href="#" class="button">Click Me!</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
This code uses a combination of HTML and CSS to create a responsive mailer that adapts to different screen sizes and devices. The CSS uses media queries to apply different styles based on the screen size.
Here's a breakdown of the code:
- The HTML structure consists of a table with a single cell that contains a nested table with three rows.
- The first row contains a header cell with a heading element (
<h1>
) that sets the font size and style for the header. - The second row contains a content cell with a paragraph element (
<p>
) that sets the font size and style for the content. - The third row contains a button cell with an anchor element (
<a>
) that sets the font size and style for the button. - The CSS uses media queries to apply different styles based on the screen size. There are three media queries:
- The first media query targets screens with a maximum width of 600px (mobile devices) and applies styles to the header, content, and button.
- The second media query targets screens with a minimum width of 601px and a maximum width of 800px (tablets) and applies styles to the header, content, and button.
- The third media query targets screens with a minimum width of 801px (desktop devices) and applies styles to the header, content, and button.
Note that this is just an example code and you may need to modify it to fit your specific needs. Additionally, you should test your mailer in different email clients and devices to ensure that it renders correctly.