Troubleshooting & How-Tos 📡 🔍 Programming

Outlook Mangling HTML <pre> Tags

It’s 2026, and I’m still dealing with Outlook rendering quirks.

I needed to plug a preformatted plain-text table into an HTML email alert. Easy, right? Just wrap it with <pre>...</pre>? NOPE! That works in literally every other email client I tested, including Gmail, Thunderbird and Roundcube. But not Microsoft Outlook.

For whatever reason, Outlook collapses all the whitespace and line breaks. Instead of a nice table, it was a mess. And of course, Outlook was the client that the people who need the alert are using.

At least it used a monospace font.

After trying a few CSS overrides that didn’t work, I went with the quick-and-dirty Web 1.0 approach:

Replace all the spaces with &nbsp; and all the line breaks with <br>.

Standards-compliant email clients handle the non-breaking spaces fine, but they render <br>\n as two line breaks, so now the HTML is one line, but it looks right when displayed. (Fortunately, the system isn’t using 7bit encoding with its line length limits!)

It’s ridiculous that we still have to do this in 2026 with one of the major tech giants’ flagship email programs for business.

So…Why?

This is after Outlook finally shifted away from using Word to render HTML.

Yeah. Word. As recently as 2023, the desktop version of Outlook for Windows still used Word. the Mac version had long since switched to using the system renderer, and of course the web version uses whatever browser you’re running. But it was the 2023 “New Outlook” that finally switched across all platforms.

That means Outlook is deliberately altering the formatting here. It might make sense if you’re rendering an actual plain-text message that’s mostly paragraphs, but inside a formatted message that explicitly marks a section as preformatted?

I wonder how long it’s done this. Maybe someone used Copilot to vibe-code this “feature” without considering where a sender would actually use this kind of markup.