BENTECH

How to Auto-Save and Live Preview HTML/CSS in VS Code

This tutorial explains how to set up Visual Studio Code for instant real-time browser preview without ever having to press Ctrl+S. While many tutorials suggest installing only a…

Watch the video tutorial on YouTube

Overview

This tutorial explains how to set up Visual Studio Code for instant real-time browser preview without ever having to press Ctrl+S. While many tutorials suggest installing only a server extension, true live updating as you type requires a combination of continuous saving and browser hot reloading. The instructor demonstrates the installation and configuration of two specific extensions: 'Save Typing' by Michel Betancourt and 'Live Server' by Ritwick Dey. Together, these extensions instantly write keystrokes to disk and reload the local development server immediately. Finally, the video demonstrates real-time feedback with HTML markup (headings, paragraphs, and lorem ipsum text) and shows instantaneous CSS styling changes, including color picking and shadow adjustments directly impacting the side-by-side browser view.

The Goal: Real-Time Live Preview Without Manual Saving

00:00

When developing front-end projects in Visual Studio Code, constantly pressing Ctrl+S or Command+S to save files and manually refreshing the browser slows down workflow. An optimal setup enables instantaneous changes on screen as soon as text is typed or deleted in the editor, without pressing any save shortcuts.

  • Eliminates the friction of manual saving and browser reloading.
  • Demonstrates real-time editing of HTML tags and content.
  • Immediate synchronization with side-by-side browser windows.

Installing Required Extensions: Save Typing & Live Server

00:50

Standard Live Server extensions only refresh when the underlying file is saved to disk. Therefore, two tools must work together: an extension that continuously saves edits on every keystroke, and a local server that detects those file updates. The instructor specifies installing 'Save Typing' by Michel Betancourt (or Auto Save typing extension) alongside the standard 'Live Server' extension by Ritwick Dey.

  • Live Server alone is not enough; files must be saved to trigger reloads.
  • Extension 1: 'Save Typing' by Michel Betancourt saves automatically on keystroke.
  • Extension 2: 'Live Server' by Ritwick Dey serves the project locally and auto-refreshes.

Launching Live Server and Verifying HTML & CSS Live Editing

03:20

Once both extensions are installed, open the HTML file. Start the server either by right-clicking the editor area and choosing 'Open with Live Server' or by clicking the 'Go Live' icon on the bottom VS Code status bar. The browser opens automatically at 127.0.0.1:5500. Any changes to HTML elements (h1, h2, paragraphs) or CSS color properties in linked stylesheets reflect instantly in the browser without manual save commands.

  • Trigger the server using the context menu ('Open with Live Server') or bottom status bar ('Go Live').
  • HTML edits and CSS modifications update live upon typing.
  • Live CSS styling adjustments (like color pickers or text-shadow changes) display without lag.