Artifact Review Docs

HTML Capabilities

What works in HTML artifact previews — CSP rules, sandboxing, and supported features.

HTML artifacts are rendered inside a sandboxed <iframe> with a Content Security Policy (CSP). This keeps reviews secure while supporting the most common AI-generated HTML patterns.

What Works

FeatureStatusNotes
Inline <style> tagsSupportedFull CSS support
Inline <script> tagsSupportedJavaScript executes normally
Inline event handlersSupportedonclick, onload, etc.
data: URIsSupportedImages, fonts via data URIs
SVG (inline)SupportedIncluding animated SVG
Canvas / WebGLSupported2D and 3D rendering
CSS animationsSupported@keyframes, transitions
Web fonts (inline)SupportedVia @font-face with data URIs
Responsive layoutsSupportedMedia queries work normally
<form> elementsSupportedRenders but submissions are sandboxed
Mermaid diagramsSupportedVia inline script

What Doesn't Work

FeatureStatusReason
External <script src>BlockedCSP blocks remote script sources
External <link> stylesheetsBlockedCSP blocks remote style sources
CDN-hosted librariesBlockedNo external network requests from preview
fetch() / XMLHttpRequestBlockedNo outbound network from sandbox
<iframe> inside artifactBlockedNested iframes are not allowed
localStorage / sessionStorageBlockedSandboxed origin has no storage access
CookiesBlockedSandboxed origin cannot set cookies
Popups (window.open)BlockedSandbox disallows popups
Top-level navigationBlockedCannot navigate the parent frame

Tips for AI-Generated HTML

Most AI tools (Claude, ChatGPT, Cursor) produce self-contained HTML that works perfectly. If your artifact doesn't render:

  1. Bundle everything inline — move external CSS into <style> tags, external JS into <script> tags
  2. Use data URIs for images — convert image URLs to data:image/png;base64,...
  3. Avoid CDN dependencies — Tailwind CDN, Google Fonts via <link>, etc. won't load. Include the CSS directly
  4. Check the console — open browser DevTools to see CSP violations

ZIP Alternative

If your project requires multiple files (separate CSS, JS, images), use a ZIP bundle instead. ZIP artifacts serve files from storage, bypassing single-file CSP restrictions on external resources.

On this page