Skip to main content
Syllabus
On this page

Setting Up Your CSS Workspace: Linking Files & Live Server

Badar KhalilUpdated September 29, 2026 3 min read

Before writing real styles you need a clean, organized CSS workspace. In this lesson you will install a code editor, create a project folder, link a CSS file to HTML and use Live Server for instant browser refresh.

Step 1: Tools You Need

  • A code editor - Visual Studio Code (VS Code) is the most popular free choice.
  • A modern browser - Chrome, Edge, Firefox or Safari with built-in developer tools.
  • Live Server extension - reloads the page whenever you save a file.

Step 2: Create a Project Structure

Create a folder such as css-course and organize it like this:

Code
css-course/
  index.html
  css/
    style.css
  images/

Keeping CSS in its own folder makes larger projects easier to manage.

Step 3: Three Ways to Add CSS

Write CSS in a .css file and connect it inside the HTML head with the link element. One file can style many pages, and the browser caches it.

2. Internal Stylesheet

Place CSS inside a style element in the head. Useful for a single page, quick demos or critical CSS.

3. Inline Styles

Use the style attribute on one element. It has very high specificity and is hard to maintain, so use it only for quick tests or dynamic values.

MethodReusableBest for
ExternalYesReal projects
InternalOne pageDemos, small pages
InlineNoQuick tests, dynamic values
  • rel='stylesheet' tells the browser this file is a stylesheet.
  • href is the path to the CSS file, relative to the HTML file.

Understanding File Paths

  • style.css - same folder as the HTML file.
  • css/style.css - inside a css folder next to the HTML file.
  • ../css/style.css - go up one folder, then into css.

About @import

You can import one CSS file into another with @import, but it delays loading because the browser discovers files one after another. Prefer multiple link elements or a build tool.

Step 4: Install and Use Live Server

  1. Open VS Code and open the Extensions panel (Ctrl+Shift+X, or Cmd+Shift+X on Mac).
  2. Search for Live Server and click Install.
  3. Open your project folder with File > Open Folder.
  4. Right-click index.html and choose Open with Live Server, or click Go Live in the bottom status bar.
  5. Your browser opens at an address like http://127.0.0.1:5500. Edit and save the CSS: the page updates instantly without a manual refresh.
  • Prettier - automatic code formatting.
  • Stylelint - catches CSS errors and enforces conventions.
  • CSS Peek or IntelliSense - jump from a class in HTML to its CSS definition.
  • Color Highlight - shows color previews in the editor.

Essential Starter Template

Every page should include the charset and viewport meta tags. The viewport tag is required for responsive design on phones.

Troubleshooting: My CSS Is Not Working

  • Wrong path - open DevTools Network tab; a 404 on style.css means the href is wrong.
  • Typos - it is style.css not styles.css; file names can be case-sensitive on servers.
  • Link placed outside head - keep the link element in the head.
  • Unsaved file - save with Ctrl+S (or enable Auto Save).
  • Browser cache - do a hard refresh (Ctrl+Shift+R).
  • Syntax error - a missing brace or semicolon breaks following rules.
  • Opening the file directly (file://) works for simple pages, but a local server is closer to real hosting and required for many modern features.

Key Takeaways

  • Use an external stylesheet for real projects.
  • Link it with link rel='stylesheet' href='path' inside the head.
  • Live Server gives instant reloads while you edit.
  • Add the viewport meta tag from day one.
Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself CSS
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself CSS
Output

Press Run to execute.

Exercise: Link Your StylesheetHTML

Complete the head so that the page loads a stylesheet located at css/main.css. Then set a viewport meta tag for responsive design.

Try it Yourself HTML
Output

Press Run to execute.

Show expected output
<meta name='viewport' content='width=device-width, initial-scale=1.0'> and <link rel='stylesheet' href='css/main.css'> inside the head.

This is a self-check — compare your result with the expected output above.

Was this page helpful?