# Gmail Shows an HTML Attachment as Code — How to Open It as a Page

Canonical: https://commareports.com/fix/gmail-html-attachment-shows-code
Published: 2026-11-15

> Click an .html attachment in Gmail and you get a wall of tags, not the report. Why Gmail's preview never renders HTML, how to open the file properly on desktop, iPhone and Android, and how to send one that opens in a click.

# Gmail shows the HTML attachment as code

Someone emails you `report.html`. You click it in Gmail and instead of
charts you get this:

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>body{font-family:system-ui;...
```

Or, on a phone, the Gmail app shows the same thing, a blank sheet, or
"No preview available".

The file isn't broken. You're looking at it in the wrong program.

## Why Gmail never renders it

Gmail's attachment preview is a document viewer. It renders PDFs, images
and Office files; anything it doesn't render, it shows as text. HTML is
deliberately in the second group: rendering a stranger's page inside your
mailbox would let any sender run their own markup and scripts next to your
inbox, which is exactly what phishing kits want. So the preview shows the
source, and Gmail's own safety banner may warn about the attachment too.

The same is true one hop away. **Google Drive's preview** shows source,
and **Open with → Google Docs** imports the HTML as a document, dropping
the scripts and most of the styling. Neither shows the report as it was
built.

## Open it properly

**On a computer.** Use the download arrow on the attachment chip, not the
preview. Open the downloaded file with a browser: double-click it, drag it
onto a Chrome/Edge/Firefox/Safari window, or right-click → Open with. The
address bar shows `file:///…/report.html` and the page renders, scripts
and all. If it still shows tags, the file was saved as `report.html.txt`
— [check the real extension](/fix/html-file-shows-code-instead-of-page).

**On iPhone or iPad.** Long-press the attachment in Gmail → Save to Files,
then open it from the Files app. Details and the limits of Quick Look in
[open an HTML file on iPhone](/open-html-file-on-iphone) and
[on iPad](/open-html-file-on-ipad).

**On Android.** Download it, then open the Files app → Downloads →
the file → Open with → Chrome. Gmail's own preview won't hand it to a
browser — [open an HTML file on Android](/open-html-file-on-android).

**On a Chromebook.** Download, then Files → Open with → Chrome —
[open an HTML file on a Chromebook](/open-html-file-on-chromebook).

**Just want to look at it?** Copy the source out of the preview and paste
it into the [free HTML viewer](/tools/html-viewer). It renders in a
sandbox in your browser and nothing is uploaded.

## When it opens but looks wrong

Getting it into a browser fixes the "code" problem. Two others are common
with emailed reports, because only one file made the trip:

| You see                               | Why                                                        | Fix                                                                                      |
| ------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| Unstyled page, broken image icons     | CSS and images were sibling files the sender didn't attach | [Lost CSS](/html-report-broken-css) · [Images not showing](/fix/html-images-not-showing) |
| Layout and text but empty chart boxes | The page `fetch`es data files, and `file://` blocks it     | [CORS error from origin 'null'](/fix/cors-error-file-origin-null)                        |
| Tiny page on a phone                  | No viewport tag                                            | [Report tiny on a phone](/fix/html-report-tiny-on-phone)                                 |
| `Ã©` and `â€™` instead of punctuation | Encoding guessed wrong                                     | [Weird characters](/fix/html-weird-characters)                                           |

The sender can fix all of these at once by bundling everything into one
file with the [HTML inliner](/tools/html-inliner) — or by not attaching
it at all.

## If you're the sender: send a link

Every recipient who sees tags has to know the download-then-open dance,
on whatever device they read mail on. Most won't, and some never get the
file — [Outlook and corporate gateways block HTML attachments](/fix/outlook-blocked-html-attachment)
outright.

Publish the report and put the URL in the email instead:

- **One click from Gmail, on any device**, rendered exactly as generated —
  scripts, charts and styles run inside a sandbox.
- **No filter trouble.** A link isn't an attachment, so nothing gets
  quarantined or stripped, and there's no [size limit to hit](/fix/html-file-too-big-to-email).
- **You choose who sees it**: public, password, invite-only, or your email
  domain — [sharing options](/docs/sharing).
- **Replies land on the page.** Readers pin comments to the exact chart
  they mean, instead of replying-all with a screenshot. Commenting takes a
  free sign-in, or none if you allow guest comments on the link.

Recurring report? Update the same report each run and the link in every
email keeps showing the latest version. See
[emailing an HTML report](/email-html-report) and [publish from CI](/docs/ci).

## Try it

Comma is free — unlimited reports and unlimited commenters.

**[Turn the attachment into a link →](https://commareports.com/)**

### Related

- [HTML report troubleshooting](/fix)
- [HTML file shows code instead of the page](/fix/html-file-shows-code-instead-of-page)
- [Outlook blocked the HTML attachment](/fix/outlook-blocked-html-attachment)
- [The HTML file is too big to email](/fix/html-file-too-big-to-email)
- [Email an HTML report](/email-html-report)
