Despite many platforms, social media, and websites, email marketing is a valuable aspect of the…
Coding HTML emails can feel like wrestling a greased octopus, yet with a few proven habits you’ll handle even the toughest client. This guide explains what really matters in 2025 with clear examples and tips you can use. Grab your favorite editor, brew a coffee, and let’s turn a blank .html file into an inbox‑ready masterpiece.
Why We Still Write Emails in Tables
If you hang around web forums long enough you’ll hear, “Tables are dead, long live flexbox.” That slogan is half‑true on the open web, but inside an email client the rules are older and grumpier. Gmail, Outlook, and their mobile cousins still treat CSS positioning like an optional suggestion, so the humble <table> remains the most reliable structure for consistent layouts.
The upside is predictability: a table behaves almost identically in Apple Mail and Gmail on Android, which means fewer late‑night bug hunts. The downside is that it makes your code longer and harder to read because of all the extra rows and cells. A good middle ground is to use simple two-level tables and add clear comments, so later you’ll know which <td> controls things like the hero banner.
Setting Up Your Blank Canvas
Before you write a single tag, open Notepad++ or Visual Studio Code and create an empty document. Paste an HTML‑only DOCTYPE, a <meta charset=”UTF‑8″>, and a viewport line that whispers to mobile clients to behave. That micro‑head section weighs almost nothing but prevents weird character encoding and forced zoom on small screens.
Once the head is set, drop into the body and reserve a top‑level table that spans 100 percent width, no padding or borders. This outer shell keeps rogue margins from Outlook away while letting you center the real content with a fixed‑width inner table. Save the file as welcome‑campaign.html right away; version control is friendlier when each change has a snapshot to roll back to.
Building a Reliable Skeleton With Tables
Start with a 600‑pixel‑wide inner table. After two decades of marketing experiments that width still hits the sweet spot between desktop real estate and mobile zoom ease. Add align=”center” to the parent <td> so older email clients center it properly. Then set cellpadding and cellspacing to 0 to avoid weird white lines in dark mode.
Inside that skeleton slot your header row, a hero image row, a two‑column promo row, and a footer row. Keep each row self‑contained; don’t ask a single <tr> to juggle multiple design duties. If you need a full‑width background color, nest an internal table with width=”100%” and fill its lone cell with the color —t his trick survives Outlook’s VML quirks without forcing you to write conditional comments.
Inline Styles The Unsung Heroes
Modern web developers prefer external stylesheets, but email coding plays by different rules. Inline styles work best because many email apps remove <style> tags or ignore what’s inside them. That means every <td> gets its own font‑family, font‑size, line height, and sometimes even a display:block to fight Android Gmail’s curiosity.
Yes, the code looks noisy. The reward is that you know exactly how a line of text will render in Yahoo Mail at 2 a.m. when your boss forwards a screenshot in panic. To stay sane, write your CSS once inside the <head>, then use a small Node script or a web tool like Postmark’s Styler to inline everything during your build step. Your final markup ships bulky but bullet‑proof.
Images Fonts and Other Pretty Things
Images carry emotion and click‑through power, yet they trigger download warnings if you skip the basics. Always set width, height, and a descriptive alt attribute so readers on slow connections know what they missed. For hero banners try JPEG at 120 KB or below; anything heavier risks being clipped by older Outlook versions.
Web fonts can be tricky in emails. Some apps, like Apple Mail, show Google Fonts fine, but Gmail switches to Arial. Use font-family:”Roboto”, Arial, sans-serif; for a backup. Add the rule to your headline, test it, and move on — there’s no time to fix font issues in older email apps..
Testing Till It Hurts Less
You wouldn’t launch code without a linter, so don’t send an email without device tests. First, open the file in your browser and resize it to spot any obvious issues. Then, send it to your personal Gmail, Outlook, and iCloud accounts. Finally, use Litmus or Email on Acid to check how it looks in other email clients you don’t control.
Automation helps: set up a simple script to send your HTML through an API every time you update your code. The previews will appear in your dashboard, showing how it looks in apps like AOL Alto. Spending 30 minutes on this saves you days of fixing issues if a key button isn’t working in an important email.
Responsive Tricks That Survive Client Quirks
Media queries don’t always work everywhere, but you can still make your emails look good in one column on small screens. Set images to max‑width:100% and declare table cells display:block; width:100%; when the screen dips below 620 pixels—most modern clients respect it. For Gmail apps that ignore queries, use the “hybrid” method: stack your columns as separate tables and reveal / hide them with mso‑hide:all in Outlook.
Sometimes a basic trick works better than fancy CSS. Instead of a three‑column grid, design two easily stacked 50‑50 cells. On desktop they float side by side; on mobile they sit vertically without media queries. Your design looks clean and intentional, and you don’t have to fix weird spacing caused by app updates.
Tools That Keep You Sane
Hand-coding everything sounds nice, but using a few tools saves time. Editors like Notepad++ or Sublime Text make code easier to read and edit. Tools like Parcel.io help by putting your emails together, replacing variables, and making sure images don’t get stuck in browser cache.
If design isn’t your thing, use Canva to make hero images that are the right size, and Figma to export graphics easily. Need a quick email layout? Try MJML—it turns simple code into ready-to-send HTML emails. Just be sure to check the final result—these tools are fast, but they can miss small issues.
(The only quick bullet list, promised)
Notepad++ or Sublime Text for feather‑weight editing
• Parcel or Gulp for automated inlining and image compression
• Litmus for multi‑client previews without owning every device
Common Pitfalls I Learned the Hard Way
The first is forgetting background‑color:#ffffff on your body tag. Dark mode can turn text white, but your images might still have dark logos that disappear. To keep things looking right, add a white background so everything stays clear and consistent.
Next, watch out for the sneaky right gutter. If your table goes just a bit over 600 pixels, Outlook might add an unwanted 8-pixel margin. Double-check your widths, and if you’re not sure, just make it a little smaller.
Also, avoid using <div> tags unless you really have to. Many email apps mess with them or remove their styles. Use <td>for layout, and add space with <tr> rows and height instead of margin. That way, your email will stay solid, even with future updates.
Sending Day Nerves and Last‑Minute Checks
The morning of the campaign, verify subject‑line length (under 50 characters still wins) and preview text. Broken UTF‑8 characters in that tiny snippet can tan hurt your open rates more than a bad design. Run your HTML through a spam checker and fix any sketchy words before you hit send.
Once approved, push the template into your ESP’s code editor but keep a local copy under version control. The visual editors inside some platforms like to “beautify” your markup, which often means stripping comments or re‑formatting inline CSS. Keeping the original version close helps you fix things fast if a formatting tool messes up your layout right before launch.
Pocket Guide Wrap‑Up
Even after learning all this, email coding might still feel old-school and messy — tables and styles everywhere, and tons of testing. And honestly, that’s true. But those are the trade-offs that make sure your email looks good whether it’s opened in Outlook or Gmail. If you work within those limits, keep your code clean, use light images, and have backup fonts ready, you’re already doing better than many brands still sending broken emails.
Follow these habits: save each template version, automate inlining, test on real devices, and keep your code simple and clean. The payoff is an email that renders exactly how you imagined, drives the clicks your marketing team promised, and quietly reinforces trust with your audience. With a small set of tools, some patience, and the techniques you’ve learned, HTML email coding becomes a manageable skill you can actually enjoy.
Sources:
https://selzy.com/en/blog/create-html-email-template/
https://www.freecodecamp.org/news/how-to-create-a-responsive-html-email-template/
About the author :
Vasyl Holiney is a Ukrainian content marketer who specializes in promoting brands through email newsletters. He is passionate about automation technologies and implements creative solutions to boost click-through rates.