Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fastest answer: find index.html and double-click it (or drag it into Chrome, Edge, Firefox, or another browser). The browser will show a file:// URL. That is enough for many standalone HTML/CSS/JavaScript pages. If scripts, fetch requests, modules, fonts, routing, or other browser-security rules fail from a file URL, run a small local HTTP server instead. In VS Code, Microsoft’s Live Preview extension adds an editor-connected preview and configurable refresh, while VS Code’s integrated browser can open local HTML without installing a server extension.

Choose the right preview method

Your page’s dependencies, desired refresh behavior, and project structure determine the best workflow.

Method Best for Address/context Refresh behavior
Open the file directly Simple static documents with local CSS, images and basic scripts file:// Refresh or reopen manually
VS Code Live Preview Editing in VS Code when you want an editor-connected, server-backed preview Local HTTP preview managed by the extension Automatic by default; can refresh on save or be disabled
VS Code integrated browser Opening a local HTML file inside VS Code without a separate server Local file:// resource Browser-style manual refresh
Node.js or Python server Pages that require HTTP behavior or a repeatable command-line workflow http://localhost on the server’s port Refresh in the browser; add your own file-watching tool if needed

A framework project such as React, Vue, Angular or a static-site generator should normally use its prescribed development command. Adding a generic server can bypass the framework’s transforms, routing and environment setup.

Open index.html directly in a browser

  1. Save your page and confirm that the file is actually named index.html, not index.html.txt.
  2. In your file manager, double-click the file. Choose a browser if your operating system asks which application to use.
  3. Alternatively, drag the file into an open browser window, or use the browser’s Open File command.
  4. Check the address bar. A direct preview normally begins with file://.
  5. After editing, save the file and refresh the tab. If the browser appears stuck on an old version, use a hard reload or close and reopen the file.

Use this method first for a document that only references local assets with relative paths such as css/style.css and images/logo.png. It requires no extension, Node.js installation or hosting account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

When a file URL is not enough

A browser treats file:// differently from an HTTP website. Security restrictions can block or change behavior for JavaScript modules, fetch(), requests to APIs, service workers, some font or media requests, and code that expects an origin. If the developer console reports a CORS, origin or module-loading error, move to a local HTTP server rather than weakening browser security.

Live-preview an HTML file in VS Code

Install Microsoft’s Live Preview extension

  1. Open VS Code.
  2. Select the Extensions view (the four-square icon) or press Ctrl+Shift+X on Windows/Linux, or Cmd+Shift+X on macOS.
  3. Search for Live Preview and choose Microsoft’s extension.
  4. Select Install.
  5. Open the project folder, then open index.html.
  6. Use the file’s preview action (the preview/globe control in the editor, or the command exposed by the extension). Choose its embedded or external-browser option according to where you want the page displayed.

Live Preview is most useful when your project does not already have a development server. Its README describes changes appearing as you make them by default; its settings can instead refresh on save or turn automatic refresh off.

Keep the workspace and server root correct

Open the project’s top-level folder in VS Code, not just an individual file. If index.html loads but a stylesheet, image or script is missing, check the extension’s workspace/server-root settings. The root must be the directory from which your relative paths are meant to resolve. For example, if the file contains <script src="js/app.js"></script>, the selected root should contain the js directory beside index.html.

Use VS Code’s integrated browser without a server

VS Code can open local HTML files in its integrated browser. In Explorer, right-click the .html or .htm file and choose Open in Integrated Browser. You can also use the editor tab’s context menu or the globe button in the editor toolbar when it is available.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This action requires a local file:// URL. Microsoft’s integrated-browser workflow excludes remote and virtual-workspace resources, so a file opened from a remote-only environment may not offer the same command. The integrated browser does not turn a file preview into an HTTP server; use one of the server methods below when your page needs HTTP semantics.

Serve the project over HTTP

Python’s built-in server

  1. Open a terminal.
  2. Change to the folder containing index.html:
cd /path/to/your/project
  1. Start the server:
python -m http.server

Python prints the local address and port, commonly a localhost address on port 8000. Open that address in your browser and append a path only if your index file is in a subdirectory. Stop the server with Ctrl+C.

On systems where python is not the command, try python3 -m http.server. The command serves the directory in which it was started, so starting it one level too high or too low changes how relative URLs resolve.

Node.js with http-server

With Node.js and npm installed, MDN’s documented example is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npx http-server /path/to/project -o -p 9999

This serves the project on port 9999 and opens the index page when present. Replace the path with your project directory. If the port is already occupied, choose another port and open the corresponding localhost URL. Press Ctrl+C to stop the process.

Use the project’s own development command when applicable

If the repository contains a README with a command such as npm run dev, use that command first. Framework servers commonly provide module handling, asset processing, hot reload and client-side routing that a plain static server cannot reproduce.

Refresh behavior and path rules

Manual file preview

Direct opening is simple but has no built-in watcher. Save the file, switch to the browser and reload. Browser caching can make an unchanged asset appear current; inspect the Network panel or use a hard reload when debugging cache behavior.

Live Preview

Use automatic refresh while editing, refresh-on-save for a calmer workflow, or disabled refresh when a page performs expensive initialization. If an unsaved change does not appear, verify the active editor is the file being served and that the extension is watching the correct workspace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Relative URLs

Relative URLs are resolved from the document URL. A stylesheet reference such as css/site.css expects css/site.css below the directory containing the served page. A leading slash such as /css/site.css refers to the server root, which may differ from the folder you expected. Correcting the workspace or server root is usually safer than rewriting every path.

Troubleshooting

A double-clicked page is blank

  • Open developer tools and check the Console for JavaScript errors.
  • Confirm the file contains visible body content and that the CSS is not hiding it.
  • Check every stylesheet, image and script path relative to index.html.
  • Serve the folder over HTTP if the console mentions origin, module or blocked-request errors.

CSS or images are missing

  • Check spelling, capitalization and file extensions; case differences often work on one operating system and fail on another.
  • Inspect the failed URL in the Network panel.
  • Open the correct project root in VS Code or start the terminal server from the directory that contains the expected asset folders.

Live Preview opens the wrong page

Close duplicate workspaces, open the intended project folder, and verify the extension’s server-root setting. A workspace opened one directory above or below the actual project can produce valid-looking but incorrect paths.

The integrated-browser command is missing

Make sure the resource is a local .html or .htm file and that VS Code can address it with a file:// URL. Remote or virtual workspace resources are not covered by this local-file action. Use Live Preview or a terminal server for those projects.

The port will not open

  • Read the terminal output for the actual port; do not assume it is 8000 or 9999.
  • If another process owns the port, stop that process or select a different port.
  • Ensure the server is still running and that your browser uses localhost rather than a stale tab.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a rendered image or PDF rather than an interactive local editing session, ScreenshotNeo provides a website screenshot API and MCP server. It can accept consent banners before capture and remove more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a public URL, one GET request is enough:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for all options, including full-page capture, CSS-selector elements, device and viewport settings, retina scale, custom CSS and JavaScript, waits, blocked resources, headers, cookies, geolocation, PDFs, signed links, async jobs and bulk capture.

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

An MCP server supplies take_screenshot, get_page_info and capture_pdf tools to Claude, Cursor and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Frequently Asked Questions

Do I need Live Server or Live Preview for every HTML file?

No. A basic standalone page can usually be opened directly with a file:// URL. Use a local server when the page’s browser features require HTTP or when your project supplies its own development server.

Can I preview an HTML file in Chrome from VS Code?

Yes. Open the file directly in Chrome, use Live Preview’s external-browser option, or use VS Code’s integrated browser for a local file.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does my page work online but not from file://?

A deployed site runs in an HTTP origin. Browser security and origin rules can block modules, fetch requests or service-worker behavior when the same files are opened directly from disk.

The Bottom Line

Start by double-clicking index.html. If the page needs HTTP behavior, run Python or Node from the correct project root; choose Live Preview when you want VS Code-connected refreshing, and use the integrated browser when a local file view is sufficient.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.