Skip to main content

An HTML Email Template with Basic Typography and Dark/Light Modes

Chris CoyierOctober 17, 2024About 8 minCSSArticle(s)blogfrontendmasters.comcss

An HTML Email Template with Basic Typography and Dark/Light Modes 관련

CSS > Article(s)

Article(s)

An HTML Email Template with Basic Typography and Dark/Light Modes
You can keep it chill and just use HTML email to apply a nice typeface, reign in the line length, use real links, and honor dark mode.

I don’t mind HTML email, but it really can be overdone. There is a tendency to do too much. Too much layout. Too many images. Too much text. Too many styles. The reason I don’t mind it though is that the HTML part of an HTML email offers some styling control that, when reigned in, makes for a clear and nice-looking email.

A plain text email can be nice too. The constraint of plain text can help an email get to the point and not do too much. But if we go for HTML email, we can apply just enough layout and styles to make it almost like a plain text email, only with a bit more class.

I’ve put together an HTML document that does those things. I looked at various templates and poked and prodded and tested things and have what seems to be a decent setup to accomplish those things above (and nothing more).

It’s a pretty big chunk of HTML, so I’ll pop it in here as a <details>.

::: detatils Plain Typographic HTML Template

:::

It looks like this
It looks like this

But “it looks like this” is of course a gross simplification. Looks like this… where? The email client landscape is arguably even more complicated than the browser landscape. There are email clients that use Microsoft Word (?!) as the rendering engine. There are mobile-specific and desktop-specific clients. There are native clients across platforms. There are web-based clients. There are clients from two decades ago, and clients updated last week.

I like the app Litmus for testing this stuff. It’s awfully expensive, but it allows you to see how your email will look across tons of clients and that’s pretty impressive and useful, so hey, you gotta do what you gotta do.

Here’s a selection of screenshots of this email rendering
Here’s a selection of screenshots of this email rendering

Those all turned out pretty decent across the board so I’m happy with that. I tend to focus on the extemes.

So like does Outlook 2007 on Windows look OK?
So like does Outlook 2007 on Windows look OK?

It’s not amazing, but for a 17-year-old email client, I’m going to call that a win. Web Gmail is sort of the other extreme.

It’s new, and web-based, but also has rendering challenges, so testing that in Firefox on Windows is a good test.
It’s new, and web-based, but also has rendering challenges, so testing that in Firefox on Windows is a good test.

Of course, we’ve gotta test mobile because not only is it a very different screen size it’s also an entirely different platform.

Here’s Dark Mode on Android
Here’s Dark Mode on Android

I’ll call that a win.

You’ll find that the Frontend Masters newsletter rolls like this!

With a red brand color as the links.
With a red brand color as the links.

While I was playing with all this, I was like: do we reallllly need to deal with all that <table> crap? Can’t we get away with something that looks more like just semantic HTML, particularly when we’re just trying to so little with the layout?

The answer is no, we still need the <table> layout, sadly. I gave it a shot with this HTML, which I “modernized” into more basic HTML:

Modern HTML Email (Test)
That looks fine in nice email clients like Apple Mail.
That looks fine in nice email clients like Apple Mail.
But Outlook 2007 and even modern OL Office can’t deal with the layout.
But Outlook 2007 and even modern OL Office can’t deal with the layout.

An explict goal of mine here was reigning in that width and centering it such that the typography has a good line length, and apparently that can’t be done without tables. Oh well! This kind of thing is “do it once and use it for a long time” and hey, that’s the job.


I’ve been enjoying playing with bolt.new, an AI generator for websites from StackBlitz. Just for kicks I asked it to create an over-the-top HTML email to see if we could get a good example of doing too much for this blog post. It spun up a Next.js app to do this, which is definitely over-the-top (lol) but I also sorta get it since the point is building web apps that StackBlitz is good at running.

This is what I got though
This is what I got though

Which is perfect and I take back everything bad I said about HTML emails.

An HTML Email Template with Basic Typography and Dark/Light Modes

You can keep it chill and just use HTML email to apply a nice typeface, reign in the line length, use real links, and honor dark mode.