Remember those creative and interactive emails you get in your inbox? Have you ever wondered what those emails are called and how they are developed?
Those are HTML emails and a lot goes into creating those emails.
If you want to learn the ins and outs of HTML emails, this guide is for you. Here we will talk about coding and designing HTML emails along with best practices you should follow.
Table of contents
What are HTML emails?
HTML emails or HTML mailers are the subset of Hypertext Markup Language used to create websites. Using HTML, you can add formatting and semantic markup in the emails.
These emails are often created using Cascading Style Sheets (CSS), which reflects how the email elements will be displayed. Thus, HTML provides the structure or outline of your email, while CSS adds life to it by displaying colors, images, etc.
Before we talk about how to code an HTML mailer, let’s understand the role of CSS.
HTML email marketing
HTML email marketing utilizes HTML (Hypertext Markup Language) formatting in promotional or informational emails. It enables marketers to create visually appealing campaigns with images, colors, fonts, and clickable links. HTML's flexibility allows for dynamic content like personalized greetings and product recommendations, providing a tailored and interactive experience. However, marketers should be mindful of rendering inconsistencies across email clients and devices, necessitating responsiveness optimization, adherence to best practices, and compatibility testing. HTML email marketing is powerful to engage recipients, conveying messages effectively, and driving higher conversions.
HTML email marketing uses HTML formatting in emails to create visually appealing campaigns. Marketers can incorporate design elements and dynamic content, such as personalized greetings and product recommendations. However, rendering inconsistencies across email clients and devices requires optimization, adherence to best practices, and compatibility testing. HTML email marketing is effective in engaging recipients and achieving higher conversions.
HTML Email Languages And Frameworks
HTML email languages and frameworks are tools and resources designed to facilitate the development of effective and visually appealing emails. They offer solutions for coding clean, responsive emails that work well across different email clients.
HTML email languages, such as HEML and MJML, provide markup languages specifically tailored for email development. They simplify the process by eliminating the need to handle email-specific quirks and styling paradigms. With these languages, developers who are already familiar with HTML and CSS can quickly start creating professional-looking emails.
HTML email frameworks, such as Maizzle and Foundation for Emails, go a step further by providing a structured framework and additional features. These frameworks often integrate with popular CSS frameworks like Tailwind CSS, offering ready-made projects, templates, and reusable components that save time and effort. They also address responsive design challenges, ensuring that emails are optimized for different devices and email clients.
What is the role of CSS in HTML emails?
CSS, or Cascading style sheets, acts as a design blueprint in your HTML code. It describes how HTML elements, such as the color, headers, tables, images, etc., will line up and display in the email.
There are three ways you can add CSS in HTML. They are as follows:
1. External stylesheets
An external style sheet is a separate CSS file you can access by creating a link within the head section of your HTML. An external stylesheet may look like this:
<head> <link rel="stylesheet" type="text/css" href="style.css"> </head>
The code above,
"style.css" is a plain text file separated from your HTML code. The style is the file's name and can differ for different users.
Most email clients don’t support external stylesheets. Hence, it is a best practice not to use them.
2. Embedded stylesheets
As the name suggests, these sheets are embedded in the HTML using the
<style> element. The support for this sheet is also minimal across email clients.
For example, as per Litmus data, email clients such as Mail.ru, Android 5.1, Android 6.0, Gmail App IMAP (Android), Windows 10 Mail don’t display these sheets in HTML mailer.
3. Inline stylesheets
Inline CSS are generally the safest way to ensure rendering compatibility across various email clients, programs, and devices.
With inline styles, code is applied directly to HTML elements in each line of the HTML. A CSS inline sheet may look like this:
<span style="font-size: 24px; font-family: Arial, sans-serif; color: #222222;">Hello!</span>
How to code HTML emails
This is the part where you begin to create emails. So, let’s get started.
• Select a doctype
A doctype is a document type declaration (DTD). These declarations tell an email client what version of HTML you are using so that it can properly render your email to the viewer.
Choosing a doctype is the foremost step to creating an HTML email, as, without it, there is no guarantee that email clients will display your email the way you intended.
Now, you need to decide which doctype to use for emails as there are many of them such as HTML5, HTML4.01 strict, HTML 4.01 Transitional, etc.
HTML5 is the most recent and was designed to hold multiple code forms, but as it is still evolving, the support for HTML5 is limited across email clients. For that reason, you should avoid using HTML5.
Scalero recommends XHTML 1.0 Transitional and HTML 4.01 Transitional doctype declarations:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
You can choose the correct doctype for your emails from the recommended list of doctype by W3C.
• Vector markup language and DPI scaling
After picking a doctype, you need to add the support for Vector Markup Language (VML). It is useful for ensuring that unsupported features, like background images and rounded borders, display correctly on email clients like Outlook 2007-16 and Outlook express. The code looks like this:
Dots per inch or DPI, is a measure for screen resolutions. DP scaling can also be a pain with Outlook email clients, so we suggest adding the following code inside the
<!--[if gte mso 9]> <xml> <o:OfficeDocumentSettings> <o:AllowPNG/> <o:PixelsPerInch>96</o:PixelsPerInch> </o:OfficeDocumentSettings> </xml> <![endif]-->
• Coding the email header
It’s time to create the email header. Head elements contain the information that your subscribers can’t see but is necessary for machine processing by email clients. The information is put under meta tags within a tag.
** Meta tags**
<meta> HTML element represents metadata that cannot be represented by other HTML meta-related elements, like
There are many meta tags you can add in HTML, but the following are the most useful in maintaining control over how basic aspects of your email display:
<meta name="format-detection" content="date=no"> <meta name="format-detection" content="telephone=no">
These meta tags will tell iOS devices not to turn addresses or phone numbers in their emails into links. You might want these elements to display as clickable links, but Apple’s default blue may not go with your email color scheme.
So, these meta tags will prevent such happenings and allow you to modify your links as per your preference.
<meta content="width=device-width, initial-scale=1" name="viewport" />
This tag guides email clients on how to scale the email, precisely its width. This will help maintain the position of email content to avoid any blank space next to images or text that doesn’t wrap properly.
After meta tags, add a CSS style tag to indicate that the content in your email is, in fact, CSS:
• Create email body and tables
Now, you can create the overall structure of your emails. Within the email body, add a tag for the main container with a width of 100%, as this table holds most of the email content. You should follow these guidelines while creating tables:
padding:0px; margin:0pxto the body tag to remove extra space in the email.
"role= presentation”attribute to each of your tables to help email clients know that the table is only for visual purposes, not as a data table.
- In the main table, create rows (tr) and columns (td). Within each column, create a table with a width of 600px. You can then define the content in the table.
• HTML email formating
Just like formatting paragraphs in Books, Documents, and Websites. It's important to format HTML email codes to avoid any issues in the future. Also, make sure to format the email in a professional way.
How to design HTML emails
While creating an HTML email, the design matters as much as its coding. A compelling, engaging, and responsive email design can offer a better user experience. While designing an HTML email, you should consider many elements such as buttons, typography, layout, and multimedia elements like -videos, GIFs, etc.
Each of these elements can significantly impact how your email looks and is understood by the reader. So, paying attention to them is crucial.
How to make HTML emails accessbile
When you are creating HTML emails, you must ensure email accessibility. It means every user should be able to access and read your emails regardless of their state. These states can be either human disabilities or technical, such as limited email client support.
For instance, colorblind people might not perceive specific colors in your emails. On the technical side, Outlook (web) doesn’t support AMP emails, but the Gmail Android app does.
Responsive HTML email templates examples
Ready to see some amazing and creative HTML email templates? We've 300+ responsive HTML & AMP email templates and all of those templates you can customize and send in a few clicks.
1. HTML welcome email template
Send them this zig-zag layout welcome email to create a lasting impression on your new signups. The banner image attracts attention, and product visuals showcase the products. The welcome coupon code is the highlight of the email.
Checkout our collection of welcome email templates
If you're looking for a wide range of responsive HTML email templates, There are several collection email templates categories like HTML Emails, Ecommerce email templates, HubSpot Email Templates, Thank you Email Templates and more. These templates are specifically designed to adapt to various screen sizes and email clients, ensuring your emails look great on both desktop and mobile devices.
💡 Browse 300+ : Email Templates to start your email marketing journey.
HTML email coding best practices
Coding emails may seem complex and confusing since email rendering has many possibilities. To ensure that your email renders well, you can follow these best practices:
These technologies are largely unsupported by email clients, so emails won’t render properly.
Currently, only Gmail, Yahoo!, and Mail.ru support AMP components in email.
• Keep HTML file size below 102KB
Each line of code in an HTML doc file affects the load timing of the email. This is why keeping your code organized and economical is essential to avoid redundant lines just taking up space.
Also, keep your HTML file size below 102KB as Gmail will clip file sizes greater than 102 KB. Besides, a file size of 100KB passes through more spam filters.
• Avoid mal-functional HTML tags
Avoid using mal-functional HTML tags. If there are any broken tags in your HTML code, the email client can mark it as spam or, worse, won’t render it correctly. That’ll hurt the email deliverability of the current and future email campaigns.
• Avoid extra spacing around images
Avoid extra spacing around an image. Instead, use display: block to remove this different spacing.
• Avoid odd numbers for sizing
Try not to use odd numbers for sizing, such as 11px, 13px, etc., as email clients sometimes add a 1px line between email elements. Such a problem is most prevalent in Outlook 2016, and your email may look like this: Unwanted lines appear in Outlook 2016 with odd font sizes.
Source: Email on Acid
• Remove comments in your CSS
Make sure to remove any comments in your CSS in your HTML code’s tag. These may ruin your code in some email clients, such as Outlook. So, it’s a best practice to eliminate them if they’re unnecessary.
• Always test your emails before sending them
The best way to know whether your code works is to test your emails. So before you send them to your final recipients, test your emails at every stage of their development.
By testing, you can spot any disparities in your emails. Hence, it will help you craft a consistent viewing experience for all your subscribers.
One step up from HTML emails: Welcome AMP emails
Moreover, AMP emails are more compatible with introducing a new Multipurpose Internet Mail Extensions (MIME) part. The MIME part allows emails to fall back to HTML templates if a provider or client doesn’t support AMP emails.
AMP for emails is still nascent, but it will revolutionize email marketing. If you want to try out AMP emails, then Mailmodo is your answer. Mailmodo offers 20+ interactive AMP widgets, such as forms, surveys, polls, carts, and calendars, that you can embed within the email and increase your conversions.
What you should do next
Hey there, thanks for reading till the end. Here are 3 ways we can help you grow your business:
Talk to an email expert. Need someone to take your email marketing to the next level? Mailmodo’s experts are here for you. Schedule a 30-minute email consultation. Don’t worry, it’s in the house. Book a meet here.
Send emails that bring higher conversions. Mailmodo is an ESP that helps you to create and send app-like interactive emails with forms, carts, calendars, games, and other widgets for higher conversions. Sign up for our 21-day free trial. Get started for free.
Get smarter with our email resources. Explore all our knowledge base here and learn about email marketing, marketing strategies, best practices, growth hacks, case studies, templates, and more. Access guides here.