How to use the HTML Viewer
- 1Paste your HTML into the editor, or edit the example.
- 2Watch the preview update as you type.
- 3Choose a width such as 390 or 768 to see how the page looks on a phone or tablet.
- 4Turn on Run JavaScript if your page needs scripts.
- 5Copy or download the finished file. Your draft is also kept in this browser.
A safe place to preview HTML
The preview runs in a sandboxed frame. Your code cannot read this site's cookies or storage, open pop-ups or navigate the page. JavaScript is off by default; turn it on only for code you trust. Even then it stays inside the sandbox.
Your code is never uploaded. The latest draft is saved in your browser's local storage so it is still there if you reload, and you can clear it at any time.
Testing responsive layouts
The width buttons resize the preview frame to common device widths: 320 (smallest phones), 390 (a typical iPhone), 768 (tablets) and 1280 (laptops). If a layout breaks, check that the page includes the viewport meta tag:
<meta name="viewport" content="width=device-width, initial-scale=1">
Tips
- Use Full screen to see the page without the editor.
- Inline your CSS in a
<style>tag; external files on your computer cannot be loaded. - Images and fonts from public URLs work as normal.
- Tab inserts two spaces so you can indent code.
A starter page
If you are starting from nothing, this is the smallest page that renders correctly in every browser:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My page</title>
<style>body { font-family: sans-serif; }</style>
</head>
<body>
<h1>Hello</h1>
</body>
</html>
The doctype matters. Without it, browsers fall back to "quirks mode" and size some elements differently. See MDN's HTML reference for what each element does.
When the preview does not match your site
| What you see | Why |
|---|---|
| Missing styles or images | The page links to a CSS or image file on your computer. Inline the CSS, or use a public URL. |
| Buttons and animations do nothing | JavaScript is off. Turn on Run JavaScript in preview. |
| Layout looks desktop-sized on a phone width | The viewport meta tag is missing. |
A link with spaces or & in its address breaks |
The address needs percent-encoding. Try the URL encoder. |
Inline images and styling
A small image can go straight into the page as a data URL. Create one with the Base64 encoder and paste it into the src attribute. For spacing that scales with the reader's font size, convert pixel values with the px to rem converter. The CSS gradient generator produces a background you can paste into a style tag.
Frequently asked questions
Is it safe to paste HTML from other sources?
The preview is sandboxed, and scripts are off unless you turn them on. Only enable JavaScript for code you trust.
Can I include CSS and JavaScript?
Yes. Put CSS in a style tag and JavaScript in a script tag, then switch on Run JavaScript in preview.
Is my code saved?
Your latest draft is saved in this browser only, so it survives a reload. It is never sent to our servers.
Why do my local images not show?
Files on your computer cannot be loaded from a web page. Use images hosted at a public URL, or convert small images to Base64 data URLs.
Why does my page look different without a doctype?
Without <!DOCTYPE html>, browsers use quirks mode, which sizes boxes and text differently. Add the doctype as the first line.
Does the viewer check my HTML for errors?
No. It shows what a browser renders, and browsers forgive many mistakes. To find invalid markup, run the code through the W3C validator at validator.w3.org.
Last updated · By the DailyDeskTools team
Built and written with AI assistance, then tested by hand by our team. How we make our tools