Skip to content

Help · HTML files

Google Drive shows my HTML file as code

You made a web page, uploaded the .html file to Google Drive and shared the link. Instead of your page, people see a wall of <div> tags, or the file just downloads. The same thing happens with Gmail attachments, OneDrive, SharePoint and Dropbox.

Last checked 25 October 2026

Short answer

File storage shows HTML as text on purpose: Google stopped serving web pages from Drive in August 2016, and email and storage services won't run someone else's HTML for safety reasons. To share a page that opens in the browser, put the file on a web host (GitHub Pages, Netlify Drop or Flatpage) and send that link instead.

Why it happens

A web page only works when a web server sends it to the browser with the label Content-Type: text/html. That label is what tells the browser "draw this as a page and run its scripts". File storage services deliberately don't do that for files people upload:

  • Google Drive used to let you host a site from a public folder. Google ended that feature on 31 August 2016. Today Drive previews an HTML file as plain text, and the download link saves it rather than opening it.
  • Gmail previews an .html attachment as raw code. The recipient has to download it and open it from their computer.
  • OneDrive and SharePoint download HTML files instead of displaying them in most setups, because a page served from your company's domain could read data from that domain.
  • Dropbox and Box don't render HTML from a shared link either, and Dropbox's old public-folder hosting is gone too.

The reason is the same everywhere. If a storage service ran uploaded HTML on its own domain, anyone could upload a fake login page that looked like it came from Google or Microsoft. Showing the code is the safe default, so no setting will change it.

Fix it: ways to share a page that opens in the browser

1. Use a host that serves HTML

This is the real fix. A static host gives the file its own web address and serves it as a page. Free options, roughly from least to most technical:

  • Flatpage: drop the .html file or paste the code and get a link such as quarterly-report.flatpage.page. Free for one site. Replace the file later and the link stays the same.
  • Netlify Drop: drag a folder onto the page. The site is deleted after an hour unless you claim it with a Netlify account.
  • GitHub Pages: free and solid, but you'll need a GitHub account and to put the file in a repository.

2. Send the file and tell people to download it

If the page is a single self-contained file, recipients can download it and double-click it to open it in their browser. This works for a one-off, but on phones it's awkward, and every change means sending a new file. Pages that load images or CSS from separate files will look broken.

3. Export it as a PDF

If nobody needs to click or scroll anything interactive, print the page to PDF from your browser and share the PDF. Drive opens PDFs fine. You lose animations, forms and live charts.

Check it worked

  • Open the link in a private (incognito) window. That's what a stranger sees, without your logins.
  • Open it on your phone, on mobile data. Many pages made on a laptop need a small layout fix for narrow screens.
  • Look for broken images. If they show on your computer but not online, the HTML points at files on your disk. Upload the whole folder as a zip, with relative paths.

How Flatpage handles this

Flatpage is a host for exactly this situation: you have an HTML file, a zipped folder or a PDF, and you want a link that opens in any browser without the other person needing an account. Pages are checked for malware and phishing before they go live, and each site gets its own address on our serving domain, which keeps sites apart from each other and from your account. If the page points at images you didn't upload, we show a neat placeholder rather than a broken icon, so you can spot what's missing.

If the page came from ChatGPT, Claude or another AI tool, see publishing ChatGPT HTML or hosting a Claude artifact for tool-specific tips.

Questions

Can I still host a website on Google Drive?
No. Google switched off Drive web hosting in August 2016. Drive can store and share the file, but it shows HTML as text in its preview and won't serve it as a working page.
Is there a Drive setting that makes HTML open as a page?
No. Changing the sharing setting to “Anyone with the link” only changes who can see the file. They still see the code or a download, not the page. A third-party previewer app can render it for you, but not for the people you send the link to.
Why does the file open fine on my computer but not for the person I sent it to?
On your computer, the browser opens the .html file directly from your disk. The person you shared it with opens it through Drive, Gmail or OneDrive, which show it as a document or download it. If they save it and double-click it, it usually works, but images and CSS that sat next to it on your disk won't be there.
My HTML file uses images and a CSS file. How do I share all of it?
Put the HTML file and everything it uses in one folder, keep the paths relative (images/photo.jpg, not C:\Users\...), zip the folder and upload the zip to a static host. The host serves every file from the same address, so the links between them keep working.
Is it safe to open an HTML file someone sent me?
Treat it like any attachment: only open files from people you trust. That's one reason email and storage services refuse to run HTML for you. A link to a hosted page opens in your browser's normal sandbox, like any other website.

Open your HTML file as a page

Drop the file or paste the code and get a link that works for anyone. Free for one site, no card needed.