Skip to content
Book a Call → mycocoon.life
← Back to Blog Students 10 min read

CS50 Week 8 Explained: How the Web Works, with HTML, CSS and JavaScript

Week 8 moves from programs on your own computer to programs that run across the internet. The first half explains what actually happens when you type a web address. The second introduces the three languages every web page is made of: HTML for structure, CSS for presentation and JavaScript for behaviour.

🎓
An unofficial study guide. CS50 is Harvard University's Introduction to Computer Science, taught by David J. Malan. The lectures, notes and problem sets linked here belong to Harvard and are shared under CC BY-NC-SA 4.0. This guide is Cocoon's own writing and is not affiliated with or endorsed by Harvard. Take the course itself, free, at cs50.harvard.edu/x. Part of our CS50 study series. Keep track of your progress with our free CS50 Study Tracker.
CS50 Week 8 Explained: How the Web Works, with HTML, CSS and JavaScript, pixel-art illustration
CS50 Week 8 Explained: How the Web Works, with HTML, CSS and JavaScript
Thumbnail of CS50x 2026, Lecture 8: HTML, CSS, JavaScript
Watch the lecture

CS50x 2026, Lecture 8: HTML, CSS, JavaScript

2 h 22 min · Harvard University · CS50 on YouTube

Jump to the key moments

  1. 0:43TCP/IP
  2. 11:30Ports
  3. 16:37DNS
  4. 21:52HTTP
  5. 30:25Status codes
  6. 35:30Inspect
  7. 42:20HTML
  8. 1:22:20Regular expressions
  9. 1:29:34CSS
  10. 1:43:46Bootstrap
  11. 1:51:03JavaScript

How data crosses the internet

HTTP and status codes

Browsers and servers talk in HTTP. A browser sends a request, such as GET /index.html, and the server replies with headers plus the page. HTTPS is the same conversation, encrypted. Every response carries a status code: 200 (OK), 301 (moved permanently), 404 (not found), 500 (the server broke). Your browser's developer tools, covered in the "Inspect" chapter, show you all of this live. Get comfortable with them this week.

HTML: structure

HTML is a markup language, not a programming language. It has no loops or conditions. You describe a page with nested tags like <h1>, <p>, <a href="...">, <img>, <table> and <form>, and attributes add details to a tag. Forms are how pages send data back to a server, which sets up Week 9. The lecture also shows regular expressions, which are patterns (like "looks like an email address") that a form field can check.

CSS: presentation

CSS selects elements and styles them: colour, size, spacing, layout. You can select by tag, by class (.card, reusable) or by id (#header, unique). Keeping styles in a separate stylesheet is good design, for the same reason functions are: one change updates every page. Bootstrap is a ready-made CSS framework that gives you good-looking components and a responsive layout with a few class names.

JavaScript: behaviour

JavaScript runs in the browser and can change the page after it has loaded. It works through the DOM, the tree of elements your HTML created. You select an element, listen for an event (a click, a key press, a form submission) and respond by changing text, styles or content. The syntax will look familiar after C: curly braces, if, for, and functions.

Problem Set 8: what it asks

Where people get stuck

Check yourself

What does DNS do?

It turns a domain name into the IP address of the server that hosts it.

What's the difference between a 301 and a 404?

301 means the page has moved permanently to a new address, which the response gives you. 404 means nothing exists at that address.

When would you use a class instead of an id in CSS?

Use a class when the same style applies to several elements. An id identifies one unique element on the page.

What's the DOM?

The browser's tree of the page's elements, which JavaScript reads and changes to update what you see.

Build a website with AI and see every step of how it's made in Cocoon's Build Lab.

Try Build Lab →