Skip to content
webmail.io.vn
  • Email Marketing
webmail.io.vn
  • Email Marketing

How to design emails with HTML and CSS for marketing

By admin / 4 July 2025
How to design emails with HTML and CSS for marketing

Understanding the Basics of HTML Email

HTML email is the practice of designing and sending emails using HyperText Markup Language (HTML) and Cascading Style Sheets (CSS) to control the content, layout, and visual appearance of the message. Unlike plain text emails, HTML emails allow for rich formatting, images, and interactive elements, making them a powerful tool for marketing. However, it’s crucial to understand that email clients render HTML and CSS differently than web browsers, leading to compatibility challenges.

Why HTML Email is Important for Marketing

  • Enhanced visual appeal: HTML allows you to create visually engaging emails that capture attention and reinforce your brand.
  • Improved branding: Consistent use of brand colors, fonts, and logos across emails strengthens brand recognition.
  • Greater control over layout: HTML provides precise control over the layout of your email, ensuring it looks exactly as intended.
  • Increased engagement: Rich media, interactive elements, and clear calls-to-action can boost user engagement.
  • Better tracking: HTML allows for tracking opens and clicks, providing valuable insights into email performance.

The Anatomy of an HTML Email

An HTML email is essentially a mini-website contained within an email message. It consists of the following key components:

  • HTML structure: Defines the content and structure of the email using HTML tags.
  • CSS styling: Controls the visual appearance of the email, including colors, fonts, and layout.
  • Images: Enhance the visual appeal and convey information effectively.
  • Links: Direct recipients to relevant webpages or resources.
  • Text content: Provides the core message of the email.

Setting Up Your Development Environment

Before you start designing HTML emails, you need to set up a suitable development environment. This typically involves choosing an HTML editor, a testing tool, and an email service provider (ESP).

Choosing an HTML Editor

You can use a variety of HTML editors to create your email templates. Popular options include:

  • Visual Studio Code (VS Code): A free, lightweight code editor with excellent support for HTML, CSS, and JavaScript.
  • Sublime Text: A sophisticated text editor with a clean interface and powerful features.
  • Adobe Dreamweaver: A professional-grade web design tool with a visual interface and code editing capabilities.
  • Online HTML editors: Services like Mailchimp, BeeFree.io and Stripo offer drag-and-drop interfaces and code editing, but might have limitations depending on the subscription plan.

Testing Your Emails

Testing your emails is crucial to ensure they render correctly across different email clients and devices. Consider these testing tools:

  • Email on Acid: A comprehensive email testing platform that provides screenshots of your email in various email clients.
  • Litmus: Similar to Email on Acid, Litmus offers email testing, tracking, and analytics.
  • Preview in Gmail, Outlook, Yahoo: Send test emails to your own accounts in different email clients to preview rendering.

Choosing an Email Service Provider (ESP)

Your ESP is responsible for sending and managing your email campaigns. Popular ESPs include:

  • Mailchimp: A popular choice for small businesses, offering a user-friendly interface and a wide range of features.
  • Sendinblue: A comprehensive marketing platform with email marketing, SMS marketing, and automation capabilities.
  • GetResponse: An all-in-one marketing automation platform with email marketing, landing pages, and webinars.
  • Constant Contact: A simple and easy-to-use email marketing platform for small businesses.

Essential HTML and CSS for Email

HTML email development requires a specific subset of HTML and CSS, as not all elements and properties are supported by all email clients. It’s crucial to understand the limitations and best practices.

HTML Structure

The basic HTML structure of an email should include the following elements:

“`html





Your Email Title





“`

  • ``: Declares the document type, typically XHTML 1.0 Transitional for maximum compatibility.
  • ``: Defines the root element of the HTML document and specifies the XHTML namespace.
  • ``: Contains metadata about the email, such as the character set, viewport settings, and title.
  • ``: Specifies the character encoding for the email. UTF-8 is recommended for broad compatibility.
  • ``: Configures the viewport for responsive design on mobile devices.
  • ``: Sets the title of the email, which may be displayed in the browser tab or email client window.</li> <li>`<body>`: Contains the main content of the email.</li> </ul> <h3>Common HTML Tags</h3> <p>These HTML tags are generally safe to use in HTML emails:</p> <ul> <li>`<br /> <table>`: Used for structuring the layout of the email. Essential for consistent rendering.</li> <li>`<br /> <tr>`: Defines a table row.</li> <li>` <td>`: Defines a table cell.</li> <li>`<a>`: Creates a hyperlink.</li> <li>`<img>`: Inserts an image.</li> <li>` <p>`: Defines a paragraph of text.</li> <li>`<br />`: Inserts a line break.</li> <li>`<br /> <h1>` to `</p> <h6>`: Defines headings of different levels.</li> <li>` <ul>`: Defines an unordered list.</li> <li>` <ol>`: Defines an ordered list.</li> <li>` <li>`: Defines a list item.</li> <li>`<span>`: A generic inline container for phrasing content.</li> <li>` <div>`: A generic block-level container. Use sparingly as support can vary.</li> </ul> <h3>CSS Styling: Inline Styles</h3> <p>Due to limited support for external and embedded stylesheets in many email clients, it’s best practice to use **inline CSS**. This means applying styles directly to HTML elements using the `style` attribute.</p> <p>Example:</p> <p>“`html</p> <p style="font-family: Arial, sans-serif; font-size: 16px; color: #333333;">This is a paragraph of text.</p> <p>“`</p> <ul> <li>**Benefits of Inline CSS:** Ensures that styles are applied consistently across different email clients.</li> <li>**Limitations of Inline CSS:** Can make your HTML code verbose and difficult to maintain.</li> </ul> <h3>Important CSS Properties</h3> <p>These CSS properties are generally well-supported in email clients:</p> <ul> <li>`font-family`: Specifies the font for the text. Use fallback fonts to ensure readability. For example: `font-family: Arial, sans-serif;`</li> <li>`font-size`: Sets the size of the text. Use pixel values (`px`) for consistent rendering.</li> <li>`color`: Sets the color of the text. Use hexadecimal color codes or named colors.</li> <li>`background-color`: Sets the background color of an element.</li> <li>`text-align`: Aligns the text horizontally (left, center, right, justify).</li> <li>`line-height`: Sets the line height of the text.</li> <li>`padding`: Adds space between the content of an element and its border.</li> <li>`margin`: Adds space around the outside of an element. Support is inconsistent; use padding on parent elements instead.</li> <li>`border`: Sets the border around an element.</li> <li>`width` and `height`: Sets the width and height of an element. Use these attributes directly on `<img>` tags as well for proper sizing.</li> <li>`display: block` or `display: inline-block`: Essential for controlling the layout of elements. Often needed for links.</li> </ul> <h3>CSS Reset</h3> <p>Email clients often have default styles that can interfere with your design. A CSS reset helps to normalize these styles, ensuring a consistent starting point.</p> <p>Example:</p> <p>“`css<br /> body, p, h1, h2, h3, h4, h5, h6 {<br /> margin: 0;<br /> padding: 0;<br /> }<br /> table {<br /> border-collapse: collapse;<br /> }<br /> “`</p> <p>Apply this CSS inline to the `<body>` tag, or within a `</p> <style>` block in the `<head>`.</p> <h3>Working with Images</h3> <p>Images play a crucial role in HTML email design. Here are some best practices for using images:</p> <ul> <li>**Optimize Images:** Reduce image file sizes to improve loading times. Use tools like TinyPNG or ImageOptim.</li> <li>**Use Alt Text:** Provide descriptive alt text for all images. This is displayed if the image fails to load and improves accessibility.</li> <li>**Specify Width and Height:** Always specify the `width` and `height` attributes for images in the `<img>` tag. This helps prevent layout issues.</li> <li>**Use Absolute URLs:** Use absolute URLs for images to ensure they are accessible from any location.</li> </ul> <p>Example:</p> <p>```html <img decoding="async" src="https://www.example.com/image.jpg" alt="A descriptive image" width="600" height="300"> ```</p> <h2>Responsive Email Design</h2> <p>With the increasing use of mobile devices, it's essential to create responsive emails that adapt to different screen sizes.</p> <h3>Media Queries</h3> <p>Media queries allow you to apply different styles based on the screen size or device characteristics. While not universally supported, they are increasingly reliable in many modern email clients.</p> <p>Example:</p> <p>```html</p> <style type="text/css"> @media screen and (max-width: 600px) { .container { width: 100% !important; } .column { width: 100% !important; display: block !important; } } </style> <p>```</p> <p>Place this within the `<head>` tag of your email. The `!important` declaration is often necessary to override inline styles.</p> <h3>Fluid Layouts</h3> <p>Use percentage-based widths instead of fixed pixel widths for elements like tables and images. This allows them to scale automatically to fit the screen.</p> <p>Example:</p> <p>```html</p> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <img decoding="async" src="image.jpg" alt="Image" width="100%"> </td> </tr> </table> <p>```</p> <h3>Stacking Columns</h3> <p>On smaller screens, you may want to stack columns vertically instead of displaying them side by side. Use media queries to adjust the display property of the columns.</p> <p>Example:</p> <p>```html</p> <table width="600" border="0" cellspacing="0" cellpadding="0" class="container"> <tr> <td width="300" class="column">Column 1</td> <td width="300" class="column">Column 2</td> </tr> </table> <style type="text/css"> @media screen and (max-width: 600px) { .column { width: 100% !important; display: block !important; } } </style> <p>```</p> <h2>Best Practices for HTML Email Design</h2> <p>Following these best practices will help you create effective and engaging HTML emails:</p> <ul> <li>**Keep it Simple:** Avoid complex layouts and excessive use of images. Focus on clear and concise messaging.</li> <li>**Use a Clear Call to Action:** Make it easy for recipients to understand what you want them to do. Use prominent buttons and clear text.</li> <li>**Test Thoroughly:** Test your emails in different email clients and devices before sending them to your entire list.</li> <li>**Optimize for Mobile:** Ensure your emails are responsive and look good on mobile devices.</li> <li>**Comply with CAN-SPAM Act:** Include an unsubscribe link and your physical address in every email.</li> <li>**Use Preheader Text:** Preheader text is the snippet of text that appears below the subject line in many email clients. Use it to provide additional context or entice recipients to open the email.</li> <li>**Consider Dark Mode:** Some email clients offer a dark mode. Test your email to see how it appears in dark mode and make adjustments as needed. Often, specifying background colors is enough to prevent unexpected color inversions.</li> <li>**Accessibility:** Ensure your emails are accessible to people with disabilities. Use alt text for images, provide sufficient contrast, and use semantic HTML.</li> <li>**Spam Testing:** Run your email through a spam checker to identify potential issues that could trigger spam filters.</li> </ul> </div><!-- .entry-content .clear --> </div> </article><!-- #post-## --> <nav class="navigation post-navigation" aria-label="Posts"> <div class="nav-links"><div class="nav-previous"><a title="Sales email templates that actually convert" href="https://webmail.io.vn/sales-email-templates-that-actually-convert/" rel="prev"><span class="ast-post-nav" aria-hidden="true"><span aria-hidden="true" class="ahfb-svg-iconset ast-inline-flex svg-baseline"><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><path d='M134.059 296H436c6.627 0 12-5.373 12-12v-56c0-6.627-5.373-12-12-12H134.059v-46.059c0-21.382-25.851-32.09-40.971-16.971L7.029 239.029c-9.373 9.373-9.373 24.569 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971V296z'></path></svg></span> Previous</span> <p> Sales email templates that actually convert </p></a></div><div class="nav-next"><a title="Creating responsive email designs for mobile audiences" href="https://webmail.io.vn/creating-responsive-email-designs-for-mobile-audiences/" rel="next"><span class="ast-post-nav" aria-hidden="true">Next <span aria-hidden="true" class="ahfb-svg-iconset ast-inline-flex svg-baseline"><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><path d='M313.941 216H12c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12h301.941v46.059c0 21.382 25.851 32.09 40.971 16.971l86.059-86.059c9.373-9.373 9.373-24.569 0-33.941l-86.059-86.059c-15.119-15.119-40.971-4.411-40.971 16.971V216z'></path></svg></span></span> <p> Creating responsive email designs for mobile audiences </p></a></div></div> </nav> <div id="comments" class="comments-area comment-form-position-below "> <div id="respond" class="comment-respond"> <h3 id="reply-title" class="comment-reply-title">Leave a Comment <small><a rel="nofollow" id="cancel-comment-reply-link" href="/how-to-design-emails-with-html-and-css-for-marketing/#respond" style="display:none;">Cancel Reply</a></small></h3><form action="https://webmail.io.vn/wp-comments-post.php" method="post" id="ast-commentform" class="comment-form"><p class="comment-notes"><span id="email-notes">Your email address will not be published.</span> <span class="required-field-message">Required fields are marked <span class="required">*</span></span></p><div class="ast-row comment-textarea"><fieldset class="comment-form-comment"><legend class ="comment-form-legend"></legend><div class="comment-form-textarea ast-grid-common-col"><label for="comment" class="screen-reader-text">Type here..</label><textarea id="comment" name="comment" placeholder="Type here.." cols="45" rows="8" aria-required="true"></textarea></div></fieldset></div><div class="ast-comment-formwrap ast-row"> <p class="comment-form-author ast-grid-common-col ast-width-lg-33 ast-width-md-4 ast-float"> <label for="author" class="screen-reader-text">Name*</label> <input id="author" name="author" type="text" value="" placeholder="Name*" size="30" aria-required='true' autocomplete="name" /> </p> <p class="comment-form-email ast-grid-common-col ast-width-lg-33 ast-width-md-4 ast-float"> <label for="email" class="screen-reader-text">Email*</label> <input id="email" name="email" type="text" value="" placeholder="Email*" size="30" aria-required='true' autocomplete="email" /> </p> <p class="comment-form-url ast-grid-common-col ast-width-lg-33 ast-width-md-4 ast-float"> <label for="url" class="screen-reader-text">Website</label> <input id="url" name="url" type="text" value="" placeholder="Website" size="30" autocomplete="url" /> </p> </div> <p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" /> <label for="wp-comment-cookies-consent">Save my name, email, and website in this browser for the next time I comment.</label></p> <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="Post Comment" /> <input type='hidden' name='comment_post_ID' value='351' id='comment_post_ID' /> <input type='hidden' name='comment_parent' id='comment_parent' value='0' /> </p></form> </div><!-- #respond --> </div><!-- #comments --> </main><!-- #main --> </div><!-- #primary --> </div> <!-- ast-container --> </div><!-- #content --> <footer class="site-footer" id="colophon" itemtype="https://schema.org/WPFooter" itemscope="itemscope" itemid="#colophon"> <div class="site-below-footer-wrap ast-builder-grid-row-container site-footer-focus-item ast-builder-grid-row-full ast-builder-grid-row-tablet-full ast-builder-grid-row-mobile-full ast-footer-row-stack ast-footer-row-tablet-stack ast-footer-row-mobile-stack" data-section="section-below-footer-builder"> <div class="ast-builder-grid-row-container-inner"> <div class="ast-builder-footer-grid-columns site-below-footer-inner-wrap ast-builder-grid-row"> <div class="site-footer-below-section-1 site-footer-section site-footer-section-1"> <div class="ast-builder-layout-element ast-flex site-footer-focus-item ast-footer-copyright" data-section="section-footer-builder"> <div class="ast-footer-copyright"><p>Copyright © 2025 webmail.io.vn</p> </div> </div> </div> </div> </div> </div> </footer><!-- #colophon --> </div><!-- #page --> <script type="speculationrules"> {"prefetch":[{"source":"document","where":{"and":[{"href_matches":"\/*"},{"not":{"href_matches":["\/wp-*.php","\/wp-admin\/*","\/wp-content\/uploads\/*","\/wp-content\/*","\/wp-content\/plugins\/*","\/wp-content\/themes\/astra\/*","\/*\\?(.+)"]}},{"not":{"selector_matches":"a[rel~=\"nofollow\"]"}},{"not":{"selector_matches":".no-prefetch, .no-prefetch a"}}]},"eagerness":"conservative"}]} </script> <div id="ast-scroll-top" tabindex="0" class="ast-scroll-top-icon ast-scroll-to-top-right" data-on-devices="both"> <span class="ast-icon icon-arrow"><svg class="ast-arrow-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" width="26px" height="16.043px" viewBox="57 35.171 26 16.043" enable-background="new 57 35.171 26 16.043" xml:space="preserve"> <path d="M57.5,38.193l12.5,12.5l12.5-12.5l-2.5-2.5l-10,10l-10-10L57.5,38.193z" /> </svg></span> <span class="screen-reader-text">Scroll to Top</span> </div> <script src="https://webmail.io.vn/wp-includes/js/comment-reply.min.js?ver=6.8.2" id="comment-reply-js" async data-wp-strategy="async"></script> <script id="astra-theme-js-js-extra"> var astra = {"break_point":"921","isRtl":"","is_scroll_to_id":"1","is_scroll_to_top":"1","is_header_footer_builder_active":"1","responsive_cart_click":"flyout","is_dark_palette":""}; </script> <script src="https://webmail.io.vn/wp-content/themes/astra/assets/js/minified/frontend.min.js?ver=4.11.3" id="astra-theme-js-js"></script> <script> /(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1); </script> </body> </html>