Chapter 07 โ€ข HTML Setup

Installing VS Code for HTML

Visual Studio Code (VS Code) is a free, lightweight code editor built by Microsoft. It's the most widely used editor for HTML, CSS and JavaScript because it's fast, cross-platform, and endlessly extendable. In this lesson you'll install it, create your first HTML file, and get comfortable with the features you'll use every day.

๐Ÿ“Œ What you'll learn
  • Why VS Code is a good fit for HTML beginners
  • How to download and install it on your OS
  • How to create a project folder and open it in VS Code
  • How to create and save your first index.html
  • Which extensions actually matter when starting out
  • Useful keyboard shortcuts to speed up your workflow
  • The key parts of the VS Code interface, by name
  • How to avoid the mistakes most beginners run into

๐Ÿ’ก Why use VS Code for HTML?

You can technically write HTML in Notepad or TextEdit โ€” the browser doesn't care what you used. But a proper code editor saves you a lot of frustration as your pages get bigger.

๐Ÿ“
Plain text editorNo color, no error checking, no autocomplete. Fine for a note, painful for code.
๐Ÿ’ป
VS CodeSyntax highlighting, autocomplete, built-in terminal, live preview via extensions, and thousands of add-ons.
๐ŸŒ
Online playgroundGood for quick experiments, but you won't learn how real projects are organized on disk.

None of these are "wrong" โ€” plenty of developers still reach for a quick online playground when testing a one-off snippet. But for anything you plan to keep, save, or grow into a real site, a proper editor pays off almost immediately.

โœ…

Bottom line: VS Code gives beginners the guardrails (autocomplete, error hints) without hiding what's actually happening in your files.

โฌ‡๏ธ Download and install VS Code

STEP 1
DownloadGo to the official Visual Studio Code website and download the installer for Windows, macOS, or Linux.
STEP 2
InstallRun the installer. The default options are fine โ€” on Windows, it's worth checking "Add to PATH" if offered.
STEP 3
Create a folderMake a folder on your computer, e.g. my-html-project, to hold your webpage files.
STEP 4
Open the folderIn VS Code, use File โ†’ Open Folder and select the folder you just created.
โš ๏ธ

Don't open a single file by itself. Opening the whole project folder gives you the Explorer sidebar, so you can add images, CSS and more files as your site grows.

๐Ÿ“„ Create your first HTML file

In the Explorer panel on the left, click the "New File" icon and name it index.html. Browsers automatically load a file named index.html when you open a folder, which is why it's the standard name for a homepage.

index.html โ€” Your first HTML file
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My First Web Page</title>
</head>
<body>

  <h1>Hello, HTML!</h1>
  <p>I created my first webpage.</p>

</body>
</html>

๐Ÿ”Ž Understand the important parts

CodePurpose
<!DOCTYPE html>Declares the document as an HTML document.
<html>The root element containing the complete page.
<head>Contains page information and resources.
<title>Sets the title associated with the browser tab.
<body>Contains the content displayed on the webpage.
<h1>Creates the main heading.
<p>Creates a paragraph.

โ–ถ๏ธ Try it yourself

Edit the HTML on the left, then click Run to see it rendered on the right โ€” just like Live Server does in VS Code.

index.html
๐Ÿ“ EDIT CODE
๐Ÿ‘ LIVE PREVIEW
๐Ÿ’ก This mimics what VS Code + Live Server does automatically every time you save.

โšก Useful VS Code extensions

RECOMMENDED

Live Server

Launches a local development server and refreshes your browser automatically every time you save.

OPTIONAL

Prettier

Formats HTML, CSS and JavaScript automatically so your code stays clean and consistent.

BUILT-IN

HTML IntelliSense

VS Code provides HTML tag suggestions and autocomplete out of the box, no install needed.

OPTIONAL

Auto Rename Tag

Automatically renames the matching closing tag when you edit an opening tag.

OPTIONAL

indent-rainbow

Colors nested indentation levels, making deeply nested HTML easier to read at a glance.

OPTIONAL

Path Intellisense

Autocompletes filenames when linking images, CSS, or scripts by relative path.

OPTIONAL

HTML CSS Support

Suggests existing class and ID names from your linked CSS files while you type in HTML.

OPTIONAL

Highlight Matching Tag

Visually highlights the matching opening or closing tag as you move your cursor through the code.

โŒจ๏ธ Handy keyboard shortcuts

New fileCtrl / Cmd + N
Save fileCtrl / Cmd + S
Open terminalCtrl / Cmd + `
Format documentShift + Alt + F
Quick file openCtrl / Cmd + P
Comment lineCtrl / Cmd + /
Duplicate lineShift + Alt + Down
Command PaletteCtrl / Cmd + Shift + P

๐Ÿงญ A quick tour of the VS Code interface

Before you go further, it helps to know what each part of the window is called โ€” you'll see these names throughout every VS Code tutorial you read.

Left icon barActivity Bar
File tree panelExplorer
Where you type codeEditor
Bottom command lineIntegrated Terminal
Bottom info stripStatus Bar
Extension marketplaceExtensions View
๐ŸŽจ

Tip: Go to File โ†’ Preferences โ†’ Theme โ†’ Color Theme to pick a look that's comfortable to read for long stretches. This is purely cosmetic and won't affect your code.

๐ŸŒ Open your HTML page in a browser

After saving index.html, you can open it directly by double-clicking the file, or โ€” better โ€” right-click it in VS Code and choose Open with Live Server if you installed that extension, so the page auto-refreshes every time you save.

  • VS Code is installed.
  • Your project folder is open in VS Code.
  • Your file is named index.html, not index.html.txt.
  • Your HTML structure is complete (doctype, html, head, body).
  • The page opens successfully in your browser.

๐Ÿงช Practice task

Create a simple personal webpage with your name, a short introduction, your skills, and one link. Save it as index.html, then start organizing your project like this:

my-html-project/ โ”œโ”€โ”€ index.html โ”œโ”€โ”€ images/ โ””โ”€โ”€ css/ โ””โ”€โ”€ style.css

โš ๏ธ Common beginner mistakes

โŒ Saving as index.html.txt

Some systems hide file extensions by default, so "index.html" typed into a plain text editor can silently become "index.html.txt". VS Code shows extensions clearly, but it's worth double-checking.

โŒ Forgetting to save before checking the browser

Changes only appear once the file is saved. Live Server helps here by auto-refreshing on every save.

โŒ Opening the wrong folder

Always open the project folder itself, not a parent folder or a single loose file โ€” otherwise relative paths to images and CSS will break.

โŒ Installing too many extensions too soon

A cluttered editor slows you down. Start with Live Server and Prettier, and add more only once you know you need them.

โŒ Editing the file that Live Server is previewing from a different app

Mixing editors on the same file can cause save conflicts. Pick VS Code as your single source of truth for the project while you're learning.

๐Ÿ“ More practice

Beginner

Set up your workspace

Install VS Code, create a project folder, and save a working index.html that opens correctly in your browser.

Intermediate

Add Live Server

Install the Live Server extension and confirm your page auto-refreshes when you edit and save the file.

Challenge

Organize a small project

Create an images/ and css/ folder, link a stylesheet from your HTML, and reference an image using a relative path.

๐ŸŽฏ Interview & FAQ

Is VS Code free?

Yes. VS Code is free and open-source, maintained by Microsoft, and available for Windows, macOS, and Linux.

Do I need to know JavaScript to use VS Code?

No. VS Code itself is written using web technologies, but you don't need any programming knowledge to use it as an editor for HTML and CSS.

What's the difference between VS Code and a browser's built-in editor?

Browser dev tools are great for inspecting a live page, but changes there aren't saved to your files. VS Code edits the actual files on disk that make up your project.

Why does Live Server matter so much?

Without it, you'd have to manually refresh the browser after every change. Live Server watches your files and refreshes automatically, which speeds up the edit-save-check loop significantly.

Can I use VS Code without an internet connection?

Yes, once installed and your extensions are downloaded, VS Code works fully offline. You'll only need a connection to install or update extensions.

Do I need to install Node.js to write HTML in VS Code?

No. Plain HTML and CSS need nothing beyond a browser and a text editor. Node.js only becomes relevant later, if you start using build tools or JavaScript frameworks.

โšก Quick Summary

  • VS Code is a free, lightweight editor well suited to HTML, CSS and JavaScript.
  • Always open your whole project folder, not a single loose file.
  • Create index.html using the standard document structure.
  • Live Server auto-refreshes your browser every time you save.
  • Start with a small set of extensions and add more as you need them.
  • Learn a few keyboard shortcuts early โ€” they pay off quickly.
โžก๏ธ

Where to go next: now that your editor is set up, the next lesson digs into the structure of a web page itself โ€” the <head> and <body> โ€” so you can start building real content instead of just the boilerplate.