To build a basic website in Visual Studio Code (VS Code), open a project folder, create an index.html file plus a stylesheet, write your page, and preview it in a browser. VS Code is an editor and development workbench—not a website builder with a “New Project” wizard or ready-made templates. For a simple static site, HTML, CSS, and JavaScript are enough to get started.
What you need before you start
Install the desktop version of Visual Studio Code from Microsoft’s VS Code getting-started guide. For the first static website in this tutorial, you do not need to install a framework or JavaScript runtime. You will create files directly and use a preview in VS Code.
A workspace is the folder VS Code uses as the context for your project. Its files, terminal, source control, and development tools operate around that folder. Microsoft’s guide to getting started with VS Code explains how to open a folder and why it matters.
- Make a folder on your computer for the site, such as
my-first-site. - Open VS Code and choose File > Open Folder… (on macOS, the menu may say File > Open…).
- Select the folder you made and confirm. It should appear in the Explorer sidebar.
- If VS Code asks whether you trust the authors of files in the folder, trust it only if you created the folder or otherwise know and trust its contents. Workspace Trust can affect which project tasks and code VS Code allows to run; see Microsoft’s Workspace Trust documentation.
Create the website files
In the Explorer, select New File and create three files: index.html, styles.css, and script.js. The HTML file gives the browser the page structure, CSS controls its appearance, and JavaScript adds behavior. You can omit the JavaScript file if your first page does not need interactivity.
#1 Best Overall
Write the HTML
Put this complete page in index.html. It links the stylesheet and JavaScript file using paths relative to the HTML file, so all three files should be in the same folder.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My First Website</title>
<link rel="stylesheet" href="styles.css">
<script src="script.js" defer></script>
</head>
<body>
<main>
<p class="eyebrow">A small project</p>
<h1>Welcome to my website</h1>
<p>This page is made with HTML, CSS, and JavaScript.</p>
<button id="message-button" type="button">Show a message</button>
<p id="message" aria-live="polite"></p>
</main>
</body>
</html>
The defer attribute tells the browser to load the script without holding up HTML parsing, then run it after the document has been parsed. The viewport setting helps the page use the device’s screen width on phones.
Style the page
Put this in styles.css:
:root {
font-family: system-ui, sans-serif;
color: #172033;
background: #f3f6fb;
}
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
}
main {
width: min(42rem, calc(100% - 2rem));
padding: 2rem;
background: white;
border-radius: 1rem;
box-shadow: 0 1rem 3rem rgb(23 32 51 / 10%);
}
.eyebrow {
color: #4353c7;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
}
button {
padding: 0.7rem 1rem;
border: 0;
border-radius: 0.5rem;
color: white;
background: #4353c7;
font: inherit;
cursor: pointer;
}
button:focus-visible {
outline: 3px solid #172033;
outline-offset: 3px;
}
Add a small interaction
Put this in script.js:
const button = document.querySelector("#message-button");
const message = document.querySelector("#message");
button.addEventListener("click", () => {
message.textContent = "Your first website is working.";
});
The button’s click handler changes the message text. This example is intentionally self-contained: it needs no package manager, build step, or server-side code.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Preview the site in VS Code
There are two distinct preview routes in the official VS Code documentation: use the desktop editor’s Integrated Browser for a straightforward HTML preview, or install Microsoft’s Live Preview extension for a local development server with live reload. You do not need both for this starter page.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Option 1: Integrated Browser
- Save all three files.
- Open
index.htmlin the editor. - Open the Command Palette with Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on macOS.
- Search for and choose Simple Browser: Show, then enter the local page URL or open the HTML file using the available browser preview command in your VS Code version.
Microsoft’s HTML in Visual Studio Code documentation describes the Integrated Browser and updates while editing. The exact available command can vary with VS Code version and installed extensions. A direct file preview is useful for static pages; it is not a substitute for the server and build environment a framework or server-dependent site may require.
Option 2: Microsoft Live Preview
- Select the Extensions icon in the Activity Bar, or press Ctrl+Shift+X / Cmd+Shift+X.
- Search for Live Preview, check that the publisher is Microsoft, and open the listing to inspect its details.
- Select Install.
- Open
index.html, then use the editor’s preview action or the extension command to launch the preview.
Microsoft’s beginner tutorial uses Live Preview to launch a local development server with live reload. The extension is an optional addition: use it when you want the server-based preview and automatic refresh, rather than installing extensions by default.
Rank #3
Know what VS Code does—and does not—provide
VS Code includes language support for HTML, CSS, and JavaScript, including editing assistance such as syntax highlighting and other language features. Microsoft describes its built-in and extension-based support in Programming Languages. Extensions can add capabilities for a particular framework or workflow, but VS Code itself does not create a framework project for you.
Microsoft’s FAQ states that VS Code does not include a “File > New Project” dialog or preinstalled project templates. A framework site may require a runtime, package manager, framework tooling, or build command chosen for that project. Follow the framework’s current setup instructions rather than assuming that installing VS Code installs those dependencies.
Free tools Windows power users keep installed
One-click scans. No signup required.
Desktop VS Code or VS Code for the Web?
VS Code for the Web runs in a browser and is useful for browsing repositories and making lightweight edits without installing the desktop application. It has important limits: the terminal and debugger are unavailable there, and only some extensions run. Choose desktop VS Code when the project needs local tools, a terminal, debugging, or a fuller extension environment.
Rank #4
- 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
Install extensions selectively
Extensions are optional. In the Extensions view, search for the tool you need, inspect its publisher and listing details, and install it only when it serves your project. Microsoft’s extension documentation covers searching and installing extensions. For this basic site, Live Preview is the only extension suggested here, and the Integrated Browser may be sufficient instead.
Common problems and fixes
- The preview is blank or says the file cannot be found. Confirm that
index.htmlis saved in the folder opened in VS Code, and that the preview points to that file. A filename such asindex.html.txtis not the same file. - The page appears unstyled. Check that the stylesheet is named exactly
styles.cssand sits besideindex.html. The HTML link’shrefmust match the actual filename and relative path. - The button does nothing. Confirm the JavaScript file is called
script.js, is in the expected folder, and the script tag’ssrcmatches. Also check that the HTML IDs match the selectors in the script and that the files are saved. - Changes are not appearing. Save the edited file first. If using a browser preview, refresh it; if using Live Preview, check that its local server is still running and reopen the preview if needed.
- A project needs a server, build process, or debugger. A direct static-file preview may not support the project’s runtime behavior. Use desktop VS Code and install or run the tools required by the framework or application. VS Code is the editor, not the runtime or project generator.
- An extension behaves unexpectedly. Recheck the publisher and extension details, disable the extension to isolate the issue, and use the editor’s built-in preview if it meets your needs.
- VS Code for the Web lacks a needed feature. Move to desktop VS Code or an appropriate remote development environment when you need a terminal, debugger, or unsupported extension.
Or skip the browser setup
If you need a screenshot of a finished page rather than a live coding preview, ScreenshotNeo is a website screenshot API and MCP server from ScreenshotNeo. Its one-request API can return an image or PDF. See the ScreenshotNeo API documentation for parameters and response details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Replace the example URL with the page you want to capture and provide your API key. ScreenshotNeo removes supported cookie-consent banners, newsletter popups, and chat widgets before a capture; those cleanup steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Best Value
Frequently Asked Questions
Do I need an extension to run HTML in VS Code?
No. You can use the desktop editor’s Integrated Browser for a simple preview. Microsoft’s Live Preview extension is an optional route when you want a local development server with live reload.
Can I build a website using VS Code in a browser?
VS Code for the Web supports lightweight editing, but it does not provide a terminal or debugger and only some extensions work there. Use desktop VS Code when your project needs local tools or debugging.
Does VS Code include website templates or a New Project button?
No. VS Code is an editor and workbench; project templates and framework setup come from the tooling you choose.
Quick Recap
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.

