30 Mins

1. Introduction to the Web

How websites work

Websites operate through a request-response cycle. When you enter a URL, your browser sends an HTTP request to a server, which processes the request and sends back files.

The browser then interprets these files to render the visual interface. This cycle is the fundamental building block of the internet experience.

Operator Note: Understanding the path of a request is crucial for debugging network errors in the browser console.
Text
Client Request -> Internet/DNS -> Server Response -> Rendering

Client vs Server

The client refers to the user's browser or device, which handles the frontend interface. The server is the remote computer that stores data and processes logic.

The server sends raw assets like files to the client, while the client reconstructs them into a navigable web page.

Operator Note: Always remember that the client side is publicly viewable by users, so never store sensitive secrets there.
Text
Browser (Client) <--- Request/Response ---> Web Server

Browsers and Rendering

Browsers act as an interface layer that parses HTML, CSS, and JavaScript. The engine converts these instructions into a Document Object Model (DOM).

Modern browsers follow W3C standards to ensure consistency, though engines like Chromium or Gecko may handle complex layout calculations slightly differently.

Operator Note: Test your website in multiple browsers to ensure cross-platform compatibility.
Text
Source Code -> DOM Tree -> CSSOM Tree -> Render Tree -> Painting

HTML

The <html> element is the root of the document, but content resides in semantic tags like <main>, <article>, and <header>. HTML provides the structure of the document.

Using semantic tags helps screen readers navigate your content and boosts SEO, making your structure clear to search engine crawlers.

Operator Note: Always use semantic elements instead of generic <div> tags to improve accessibility.
HTML
<main>
  <h1>Welcome</h1>
  <p>Content goes here.</p>
</main>

CSS

CSS is used to style elements and manage layout. By selecting elements with tags or classes, you apply properties that determine appearance.

Separating CSS from HTML keeps your code clean and allows you to update the look of your entire site from one central stylesheet.

Operator Note: Use external stylesheets instead of inline styles for better maintainability.
CSS
.container {
  display: flex;
  color: #333;
}

JavaScript roles

JavaScript provides interactivity. It can manipulate the DOM, fetch data from servers asynchronously, and handle user events.

While HTML and CSS are static, JavaScript brings pages to life, allowing for complex UI behaviors and data-driven updates.

Operator Note: Keep JavaScript files at the bottom of the body or use the defer attribute to avoid blocking page rendering.
JavaScript
document
  .querySelector('button')
  .addEventListener('click', () => alert('Hello!'));
HTML
<!-- Try it: defer -->
<script src="app.js" defer></script>
<script src="analytics.js" async></script>

Setting up VS Code

VS Code is a powerful editor that provides intellisense, error highlighting, and extensibility. It is the industry standard for web development.

Configuration is straightforward; once installed, you can optimize your workspace by installing extensions that automate repetitive tasks.

Operator Note: Use the "Auto Save" feature in VS Code to ensure you never lose progress.
Text
Settings -> Extensions -> Install 'Live Server'

Installing Live Server

Live Server is a VS Code extension that launches a local development server with a live reload feature. Every time you save a file, the browser updates automatically.

This tool eliminates the need to manually refresh the browser after every minor code change, significantly speeding up the development workflow.

Operator Note: If Live Server fails to launch, ensure your workspace is a root folder and not just an individual file.
Text
Go to Extensions icon -> Search 'Live Server' -> Click Install

Folder structure

A standard project folder separates concerns by keeping styles in a css directory and scripts in a js directory.

Consistent folder structures make it easier to manage large projects and ensure assets like images and fonts are correctly linked.

Operator Note: Always use relative paths (e.g., ./css/style.css) to ensure your project works when moved to a different folder.
Text
/project-root/index.html /css/style.css /js/main.js /assets/logo.png

Knowledge Check

Ready to test your understanding of 1. Introduction to the Web?

Back