Loading

T1 HTML · Lesson 1

How the web works: from an address to a page

What happens in the second after you press Enter: the parts of a URL, DNS turning a name into a number, the request and the response, status codes, the Network tab, and what HTTPS protects.

  • name every part of a URL and read each with the URL value
  • say what DNS does, and what localhost and ports are
  • describe a request and a response: method, status, headers, body
  • read any status code by its family, from 200 to 503
  • watch requests in the Network tab, and say what HTTPS proves
About 60 minutesChecked against Node.js on the laptop (the kit runs every code block with it) 22.23.1 (2026-10-26)Play this lesson's games

The back cover

Pressing Enter on a web address sets off a short chain of events that takes less than a second. The address is split into its parts. A name is turned into a number. A request goes out, a response comes back, and the browser draws a page.

These pages follow that chain one link at a time. They show the parts of an address and the internet's contact list that turns names into numbers. Then come the plain-text conversation between a browser and a server, and the three-digit codes that say how each answer went.

The last part shows how to watch every request of a page in the browser's own tools, and what the S of HTTPS protects, and what it does not.

Before you start

The story: The journey of a notice

Master Tobin of the Masons takes you up the spiral stair of the Inkwell message tower. At the top, a glass panel glows with a notice from the harbour office, right across the city.

"Nobody carried that here by hand," Tobin says. "So how did it come?" You look out at the fog, the rooftops, the other towers blinking in the dark. Somewhere out there is the harbour office's tower. Somehow its words crossed the city to this glass.

"When you can tell me every step of that journey," Tobin says, "you may come to the Masons' Hall."

This is the first lesson of the HTML step: before writing a page, we follow how a page travels to you. It follows one ordinary moment, typing an address and pressing Enter, and shows the steps that happen in the second before a page appears. It builds on these ideas from Learning to learn and from daily life; each has a tiny example.

What you already knowA tiny exampleWhere it comes back
Strings, and their properties and methods."chai".length is 4; "Pune".includes("un") is true.An address is a string with parts you can read one by one.
=== and true or false."https:" === "https:" is true.Checking which part of an address is which.
The terminal and node file.js.node hello.js prints Namaste from Node.A tiny server runs in the terminal in this lesson.
An error report.TypeError: ... at line 1.A badly written address gives its own TypeError.
The browser's console.F12, then Console.Its neighbour, the Network tab, shows every request a page makes.
A postal address has parts in an order.house, street, city, PIN code.A web address has parts in an order too.
A phone's contact list.You tap Asha; the phone dials 98765 43210.DNS turns a site's name into its number.
Ordering at a counter.You ask for a chai; the counter answers with a chai or with sorry, none left.A browser asks; a server answers, always with a status.
A receipt says what happened.Paid, refunded, declined.Every answer from a server starts with a status code.
A sealed envelope.Only the person it is for can open it.HTTPS seals what travels between you and a site.

By the end of this lesson you will be able to:

  • name every part of a web address, and read each part in code with the URL object;
  • say what DNS does, and why a site needs both a name and a number;
  • describe a request and a response, with their method, status, headers and body;
  • read a status code and say what kind of answer it is, from 200 to 503;
  • watch a page's requests in the browser's Network tab, and say what HTTPS protects.

In one line

This lesson follows one address from the moment you press Enter to the moment the page arrives, using strings, the terminal and the console from T0.

The parts of a web address

At a glance

A URL, a Uniform Resource Locator, is the full address of one thing on the web: a page, a picture or a file. It has up to five parts, always in the same order. The scheme says how to talk to the site. The host names the computer. The path picks one thing on that computer. The query adds details as name and value pairs after a question mark, and the fragment marks a place inside the page.

The fragment never travels to the server; the browser uses it to scroll. In JavaScript, new URL(...) reads an address into its parts, each one a string.

Take a guess: Does the part of an address after the # sign ever reach the server?

An Indian postal address has parts in a fixed order: the house, the street, the area, the city, the PIN code. A postman reads it from the end: first the PIN code to reach the right post office, then the street, then the house. A web address is the same kind of thing, with its own parts in its own order.

URL

Short for Uniform Resource Locator: the full address of one thing on the web, such as a page, a picture or a file. People also call it a web address or a link.

Here is the address of this school's atlas, searched for the word join, opened at a part of the page called rows:

https://study.rohannetworks.com/tech/atlas/?q=join#rows
PartHereWhat it says
Scheme (also called the protocol)https:how to talk to the site: HTTP, sealed (the S is for secure)
Host (the domain name)study.rohannetworks.comwhich computer on the internet to talk to
Path/tech/atlas/which thing on that computer, like a folder and a file
Query?q=joinextra details for the request, as name=value pairs, after a question mark
Fragment#rowsa place inside the page; it never travels to the server, the browser uses it to scroll

Reading the parts in code

JavaScript has a built-in kind of value for addresses, called URL. You make one by writing new URL(...) with the address as text. The word new makes a fresh value of a kind; the JavaScript steps explain it fully. The value it makes has a property for each part:

const u = new URL("https://study.rohannetworks.com/tech/atlas/?q=join#rows");
console.log(u.protocol);
console.log(u.hostname);
console.log(u.pathname);
console.log(u.search);
console.log(u.hash);
https:
study.rohannetworks.com
/tech/atlas/
?q=join
#rows

Each property is a string, so everything from T0 works on it: u.hostname.length, u.pathname.includes("atlas"), u.protocol === "https:".

The query: name and value pairs

Many addresses carry details in the query. A train search, for example, needs a starting station, a destination and a date. Each pair is written name=value, and pairs are joined with &. The URL value reads them for you with searchParams.get(name).

const u = new URL("https://www.irctc.co.in/search?from=PUNE&to=CSMT&date=2026-11-02");
console.log(u.searchParams.get("from"), u.searchParams.get("to"), u.searchParams.get("date"));
console.log(u.searchParams.get("class"));
PUNE CSMT 2026-11-02
null

A name that is not in the query gives null, the deliberate nothing of lesson 2 of Learning to learn, not an error. The address above is written by hand for this lesson, to show the shape: the real railway site uses its own addresses.

A common mistake

Leaving out the scheme. People type addresses without https:// every day, and browsers fill it in. Code does not.

const u = new URL("study.rohannetworks.com/tech/");
Uncaught TypeError: Failed to construct 'URL': Invalid URL
    at line 1

That is Chrome's wording, the one you see when you press Run here. Node says the same in fewer words: TypeError: Invalid URL. The URL value belongs to the browser and to Node, not to the JavaScript language itself, so each words its own errors, as the engines did in lesson 2 of Learning to learn.

Worked example 1

A link in a message reads https://shop.example.com/products/chai-masala?size=250g&qty=2#reviews. Use the URL value to print the product's path, the size, the quantity and the place on the page.

What we have: one address with a path, two query pairs and a fragment

What we need: four values printed with labels

The plan: make a URL value, then read pathname, the two query values and hash

const u = new URL("https://shop.example.com/products/chai-masala?size=250g&qty=2#reviews");
console.log("path:", u.pathname);
console.log("size:", u.searchParams.get("size"));
console.log("quantity:", u.searchParams.get("qty"));
console.log("place on page:", u.hash);
path: /products/chai-masala
size: 250g
quantity: 2
place on page: #reviews
  1. The quantity comes back as the text 2: everything in an address is text. Turn it into a number with Number before any sum, as T0 taught.

/products/chai-masala, size 250g, quantity 2, and the page opens at #reviews.

Check: each printed value is the piece of the address between its markers: the path up to ?, each pair between ? and &, the fragment after #.

Worked example 2

Two addresses differ only in capital letters: HTTPS://Study.RohanNetworks.COM/Tech/ and https://study.rohannetworks.com/tech/. Are they the same?

What we have: two addresses that differ in capitals

What we need: which parts care about capitals

The plan: let the URL value tidy each part, then compare

const u = new URL("HTTPS://Study.RohanNetworks.COM/Tech/");
console.log(u.protocol, u.hostname, u.pathname);
https: study.rohannetworks.com /Tech/
  1. The scheme and the host are made small: names of computers ignore capitals.
  2. The path keeps its capital T: paths may care about capitals, depending on the server.

The scheme and host are the same; the path may not be: /Tech/ and /tech/ can be two different pages.

Check: the URL value lowered only the parts that never care about capitals, and kept the path as written.

When you are stuck: reading an address

Find the markers: :// after the scheme, the first / after the host, ? before the query, & between pairs, # before the fragment.

Let the URL value do it: make new URL(...) and print each property.

If you get Invalid URL, check that the address starts with a scheme such as https://.

Your turn

const u = new URL("https://example.com/tickets?from=PUNE");
console.log(u.hostname, u.pathname, u.searchParams.get("from"));
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
example.com /tickets PUNE
  1. The host is between :// and the next /.
  2. The path is /tickets.
  3. The query pair from=PUNE gives PUNE.

It prints example.com /tickets PUNE.

Which part of a URL never reaches the server?Tap to reveal
  1. The browser uses it to scroll within the page.

The fragment, the part after #.

What does u.searchParams.get("page") give when the address has no page pair?Tap to reveal
  1. A missing name is deliberate nothing, not an error.

null.

Did you know?

The PIN code: an address in six digits

India's postal index number, the PIN code, was introduced on 15 August 1972 by Shriram Bhikaji Velankar of the Ministry of Communications. It was made because of confusion over places with the same names, and because addresses were written in many languages. Each of its six digits narrows the search: the first gives the postal zone, the second the sub-zone, the third the sorting district, and the last three the post office.

Why it fits here: A URL works the same way: its parts, read in a fixed order, narrow the search from the whole internet down to one thing.

Sources: Wikipedia: Postal Index Number; Manorama Yearbook: What is PIN Code?

The two slashes nobody needed

Tim Berners-Lee, who created the World Wide Web, later said that the two slashes after https: in every web address were unnecessary. He could easily have designed addresses without them, he told the Times newspaper in 2009, adding that it seemed like a good idea at the time. He also said he wished he had used slashes in place of the dots between the parts of a domain name.

Why it fits here: Each mark in a URL has a job, and the order is fixed. Even its creator would change a few marks if he could start again.

Sources: BBC News: Berners-Lee 'sorry' for slashes; Wikipedia: URL

In one line

A URL is scheme, host, path, query and fragment, in that order; new URL(...) reads each part as a string, and searchParams.get reads one query value, or null.

DNS: from a name to a number

At a glance

Computers find each other by number, an IP address, but people remember names. The Domain Name System, DNS, is the internet's contact list: it turns a name such as study.rohannetworks.com into the number of the computer that serves it. A lookup asks in a chain and stops at the first place that knows: the browser's own memory, the operating system, then a resolver run by an internet provider.

A resolver that does not know asks the root servers, then the servers for the last part of the name, such as .com, and finally the site's own servers. Each answer is remembered for a while. The name localhost always means this computer, and a port is a numbered door on it.

Take a guess: Why does a site's name usually stay the same when the site moves to a new computer?

Your phone does not dial names. When you tap Asha in your contacts, it looks up her number and dials 98765 43210. You remember the name; the phone needs the number. The internet works the same way: you type a name such as study.rohannetworks.com, but computers find each other by number.

IP address

The number of a computer on the internet, such as 142.250.183.110 (four numbers from 0 to 255, joined by dots, in the older form called IPv4) or a longer form with colons (IPv6). IP stands for Internet Protocol.

DNS

The Domain Name System: the internet's contact list, which turns a domain name into the IP address of the computer that serves it.

The address above is only an example of the shape. Real addresses change as sites move between computers, which is exactly why names exist: the name stays, and DNS is updated to point at the new number.

How a lookup travels

When you press Enter, your browser needs the number for the host part of the URL. It asks in a chain, stopping at the first place that knows:

  1. The browser's own memory: did it look this name up a few minutes ago?
  2. The operating system: the laptop or phone keeps its own short memory of recent answers.
  3. A resolver: a DNS server run by your internet provider, or a public one such as Cloudflare's 1.1.1.1 or Google's 8.8.8.8. If it does not know, it finds out:
  4. The root servers point it to the servers for the last part of the name, the top-level domain (.com, .in, .org).
  5. The .com servers point it to the servers that hold rohannetworks.com's own records.
  6. Those servers give the answer: the IP address for study.rohannetworks.com.

Each answer comes with a time to live, its TTL: how many seconds it may be remembered. That is why the whole chain usually runs only the first time; afterwards, the answer is remembered nearby and arrives in a few milliseconds.

The name read from the right

A domain name is read from right to left, like a postal address from the PIN code: com, then rohannetworks, then study. Each dot separates one level, and the owner of a level decides the names below it: whoever owns rohannetworks.com can make study.rohannetworks.com, files.rohannetworks.com, and so on.

Your own computer's name

Every computer has a name for itself: localhost, which means "this computer". It always points back to the machine you are on, at the address 127.0.0.1. When you run a server on your laptop, as in the next sections, you reach it at http://localhost followed by a port number.

const u = new URL("http://localhost:4321/tech/");
console.log(u.hostname, u.port, u.protocol);
localhost 4321 http:

A port is a numbered door on a computer: one computer can run many servers, each listening at its own port. When a URL has no port, the scheme decides: 443 for https and 80 for http. The URL value then shows an empty port, meaning the usual one.

const u = new URL("https://example.com/");
console.log(u.port === "", u.hostname.endsWith(".com"));
true true

endsWith is a string job you have not met yet: it says whether a string ends with the text you give, true or false. Here it confirms that the top-level domain is .com.

Worked example 3

Read the levels of the name study.rohannetworks.com from the right, and say who decides each one.

What we have: a domain name with three levels

What we need: each level and who controls it

The plan: read from the right; each dot is a boundary

  1. com: the top-level domain, run by an organisation for the whole world.
  2. rohannetworks.com: registered by its owner with a company that sells domain names, a registrar.
  3. study.rohannetworks.com: a name the owner made under their own domain, called a subdomain.

com (the top level), rohannetworks (the owner's domain), study (a subdomain the owner made).

Check: the owner of rohannetworks.com can add a subdomain without asking anyone: this site's own file server is study-files.rohannetworks.com.

Worked example 4

A friend moves their shop's website to a new server, and for an hour some people see the old site and some the new. Explain why with what this section taught.

What we have: a site whose IP address changed in DNS

What we need: why visitors see different sites for a while

The plan: think of the TTL and the remembered answers along the chain

  1. The DNS record was changed to the new IP address.
  2. But resolvers and devices that looked the name up recently still remember the old number until its TTL runs out.
  3. So some visitors' devices still go to the old server, and others, whose memory ran out, go to the new one.

Old answers are remembered until their TTL runs out, so the change reaches everyone only gradually.

Check: lowering the TTL a day before a move makes the change spread faster, which is what careful site owners do.

When you are stuck: DNS

Remember the picture: a name in the contact list, a number dialled.

Read the name from the right: top-level domain, the owner's domain, subdomains.

localhost always means this computer; a port is a numbered door on it.

Your turn

What does DNS turn into what?Tap to reveal
  1. The phone picture: a name into a number.

A domain name into an IP address.

const u = new URL("http://localhost:3000/menu");
console.log(u.port, u.pathname);
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
3000 /menu
  1. The port is after the colon in the host part.
  2. The path is /menu.

It prints 3000 /menu.

What is the top-level domain of www.irctc.co.in?Tap to reveal
  1. Read from the right.

in, India's country domain (co.in is a level under it).

Did you know?

Before DNS, one file listed every computer

On the ARPANET, an early computer network, every computer's name and number once sat in a single file, HOSTS.TXT. It was kept by hand at the Stanford Research Institute and copied by every member. As the network grew, one list for everyone became slow and unwieldy. In November 1983 Paul Mockapetris published the design of the Domain Name System, which avoids the problems of one central list.

Why it fits here: The chain of lookups in this topic exists because one list for the whole world could not keep up.

Sources: Wikipedia: hosts (file); Wikipedia: Domain Name System; RFC 882: Domain Names, Concepts and Facilities (Mockapetris, November 1983)

Thirteen names at the root

At the top of DNS sit the root servers, and their names run from a.root-servers.net to m.root-servers.net: 13 names in all. The number 13 comes from a limit in the original design of DNS, which allowed an answer of at most 512 bytes. Behind those 13 names stands a network of hundreds of servers in many countries around the world.

Why it fits here: A lookup that no memory along the chain can answer starts at these root servers, as this topic describes.

Sources: IANA: Root Servers; Wikipedia: Root name server

In one line

DNS is the internet's contact list: it turns a name, read from the right, into an IP address, through a chain of remembered answers; localhost is this computer, and a port is a numbered door on it.

HTTP: a request and a response

At a glance

HTTP, the Hypertext Transfer Protocol, is the language a browser and a server use for a short conversation. The browser sends a request: a method such as GET, the path and query, and headers, each a name and a value. Host says which site is wanted, because one server can serve many.

The server sends back a response: a status line with a code such as 200 OK, more headers such as Content-Type, a blank line, and then the body, which is the page itself. HTTPS is the same language, sealed. A real server answers each path it is asked for with a status code of its own.

Take a guess: A request asks for a page: what does the server send first, the page itself or a short line about the page?

At a tea stall you say "one chai, please". The stall answers either with a chai, or with "sorry, no milk today". Every visit to a web page is the same short conversation, in a fixed language, between your browser and a server: the browser asks, and the server answers.

HTTP

The Hypertext Transfer Protocol: the language browsers and servers use for that conversation. A request goes from the browser to the server; a response comes back. HTTPS is the same language, sealed (the last section of this lesson).

What a request looks like

Once DNS has found the server's number, the browser sends a request. It is plain text with a fixed shape. Here is the shape of one, written out by hand for this lesson:

A request

GET /tech/atlas/?q=join HTTP/1.1
Host: study.rohannetworks.com
Accept: text/html
LineWhat it says
GET /tech/atlas/?q=join HTTP/1.1the method (GET: please give me), the path and query, and the version of HTTP
Host: study.rohannetworks.coma header: one name and value; Host says which site, because one server can serve many
Accept: text/htmlanother header: the kinds of content the browser would like back

What a response looks like

A response

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 18342

<!DOCTYPE html>
<html lang="en"> ... the page itself ...
PartWhat it says
HTTP/1.1 200 OKthe status line: the version, the status code 200, and its short reason, OK
Content-Type: text/html; charset=utf-8a header: the body is an HTML page, written in the UTF-8 alphabet of characters
Content-Length: 18342a header: the body is 18,342 bytes long
the blank linethe end of the headers
the bodythe content itself: here the page's HTML, which the next lesson reads

HTTP/2 and HTTP/3

Modern browsers and servers usually speak newer versions, HTTP/2 or HTTP/3, which send the same requests and responses in a faster, packed form instead of plain text lines. The methods, status codes and headers are the same, so everything in this lesson applies to them.

A real server, talking

Here is a complete web server for a tea stall, about a dozen lines, run with Node in the terminal. It answers the path /menu with the menu, and any other path with a 404. Then it asks itself for two pages, as a browser would, prints what came back, and stops. The code uses things that tracks T2 and T3 teach; for now, read the output.

stall.js

const http = require("node:http");
const server = http.createServer((request, response) => {
  if (request.url === "/menu") {
    response.writeHead(200, { "Content-Type": "text/plain" });
    response.end("Chai 15, Samosa 20");
  } else {
    response.writeHead(404, { "Content-Type": "text/plain" });
    response.end("No such page");
  }
});
server.listen(0, async () => {
  const port = server.address().port;
  for (const path of ["/menu", "/dessert"]) {
    const reply = await fetch("http://localhost:" + port + path);
    console.log("GET", path, "->", reply.status, reply.statusText, "|", reply.headers.get("content-type"), "|", await reply.text());
  }
  server.close();
});

Terminal

/home/asha/shop$ node stall.js
GET /menu -> 200 OK | text/plain | Chai 15, Samosa 20
GET /dessert -> 404 Not Found | text/plain | No such page

Each line of output is one conversation: the method and path that were asked for, then the status code and its reason, the Content-Type header, and the body. The path /menu exists, so it is 200 OK with the menu as plain text. The path /dessert does not, so the server answers 404 Not Found.

Worked example 5

Read the request and say what the browser asks for, from which site, and what it would like back.

What we have: the hand-written request above

What we need: the method, the path, the site and the wanted content

The plan: read the first line, then each header

  1. The first line: method GET, path /tech/atlas/, query ?q=join.
  2. Host: the site study.rohannetworks.com.
  3. Accept: it would like an HTML page.

It asks to GET /tech/atlas/?q=join from study.rohannetworks.com, and would like HTML back.

Check: the path and query are the same parts the URL value read in the first section; the request carries everything but the fragment.

Worked example 6

Change the tea stall so that it also answers /prices with the text Chai 15. Before running anything, predict the line it would print for /prices.

What we have: the server's code and its output

What we need: a prediction, using the shape of the output lines

The plan: the shape is: GET, the path, the status, the reason, the content type, the body

  1. A new path that the server answers works like /menu: 200 OK, text/plain.
  2. The body would be Chai 15.

GET /prices -> 200 OK | text/plain | Chai 15.

Check: the line follows the same shape as the /menu line; the Node.js step writes servers like this one, step by step.

When you are stuck: HTTP

Think of the tea stall: a request asks, a response answers, always with a status.

Read a request from its first line: method, path, version; then one header per line.

Read a response from its status line: version, code, reason; then the headers, a blank line, the body.

Your turn

What does the Host header say, and why is it needed?Tap to reveal
  1. One server can serve many sites.

Which site the request is for, because one server can serve many sites.

What separates a response's headers from its body?Tap to reveal
  1. Look at the response above.

A blank line.

The tea stall answered /dessert with 404. What does 404 mean?Tap to reveal
  1. It answered, but there was nothing at that path.

Not Found: nothing at that address.

Did you know?

The first HTTP was one line long

The first version of HTTP, as it was put into practice in 1991, was tiny; it later became known as HTTP 0.9. A request was a single line: the word GET, a space, and the address of a document. No other information about the browser was sent. The answer was the page itself, in HTML, and nothing more.

Why it fits here: The request and response of this topic grew from that one-line conversation, a few parts at a time.

Source: W3C: The Original HTTP as defined in 1991

In one line

HTTP is a short conversation: a request (method, path, headers) and a response (status line, headers, a blank line, a body); a real server answers each path with a status code.

Reading a status code

At a glance

Every response begins with a status code: three digits that say what happened, before anything else is read. The first digit gives the family. 1 means wait, more is coming. 2 means it worked. 3 means look somewhere else. 4 means the request has a problem, and 5 means the server has one.

The split between 4 and 5 is the most useful fact of all when something breaks: it says which side to look at. A few codes turn up again and again: 200 OK, 301 Moved Permanently, 404 Not Found and 500 Internal Server Error.

Take a guess: A page answers with 503: is the mistake in your request, or on the server?

A bank statement marks each payment with a word: credited, debited, pending, failed, reversed. You can understand a long statement by reading only those words. A status code is that word for every answer on the web: three digits that say what happened, before you read anything else.

The five families

The first digit of a status code tells you its family, the kind of answer. Learn these five and you can read any code, even one you have never seen.

First digitFamilyMeansIn the tea stall picture
1informationalwait, more is coming"one moment"
2successit workedhere is your chai
3redirectionlook somewhere else"we have moved to the shop next door"
4client erroryour request has a problem"we do not sell biryani"
5server errorthe server has a problem"the stove has broken"

The split between 4 and 5 is the most useful fact here. A 4xx code means the request was wrong: a mistyped address, a missing sign-in, a bad form. A 5xx code means the server failed: the request may have been perfectly good. When you debug, that one digit tells you which side to look at.

In code, the family is the first digit, which is the status divided by 100 and rounded down. Math.floor rounds down, just as Math.round rounds to the nearest:

console.log(200, Math.floor(200 / 100));
console.log(404, Math.floor(404 / 100));
console.log(503, Math.floor(503 / 100));
200 2
404 4
503 5

The codes you will meet most

CodeMeansReal example
200 OKit worked; here is what you asked fora results portal sends back the marks page
201 Createdit worked, and something new was madea shop's server answers a new order with its order number
301 Moved Permanentlythis address has moved for goodan old page address sends visitors to its new one
304 Not Modifiedyour saved copy is still gooda browser reuses its saved copy of a logo
400 Bad Requestthe request itself is malformeda form sends a date the server cannot read
401 Unauthorizedyou have not signed in, or your sign-in expiredopening an account page after the session ran out
403 Forbiddensigned in, but not alloweda student opening the teachers' marks entry page
404 Not Foundnothing at this addressa mistyped address, or a deleted product
429 Too Many Requeststoo many requests in a short timea payment API limiting each shop's calls a minute
500 Internal Server Errorthe server hit a bug of its ownan uncaught TypeError in the server's code
503 Service Unavailablethe server is overloaded or downa ticket site at the moment a big sale opens

The full table, with a few more codes, is in the Where-used atlas as HTTP status codes, and where each is used, and its partner table lists the methods: GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS.

A common mistake

Mixing up 401 and 403. 401 means "I do not know who you are": sign in. 403 means "I know who you are, and you may not": signing in again will not help. The names are confusing for historical reasons; the meanings are not.

Worked example 7

A friend's shop site shows a page that says 502 Bad Gateway. Their customer asks whether the customer did something wrong. Answer with the families.

What we have: a 502 status

What we need: whose problem it is

The plan: read the first digit, then the code's meaning

console.log(Math.floor(502 / 100));
5
  1. Family 5: a server error, not the customer's.
  2. 502 Bad Gateway in particular: a server in the middle got a bad answer from the one behind it, for example the shop's front server could not reach its app server.

No: a 5xx code is the server's problem; the shop's own servers need fixing.

Check: the same request will likely work once the server behind is back, which is what 5xx predicts.

Worked example 8

A page that worked yesterday now gives 404, and the address has a capital letter in its path: /Products/chai. What do you check first?

What we have: a 404 for an address with a capital in its path

What we need: the most likely cause

The plan: 4xx means look at the request; recall that paths may care about capitals

  1. 404 is a client error: the server is fine, the address is the problem.
  2. The first section showed that paths may care about capitals.
  3. Try /products/chai in small letters, and check the link that sent you there.

Check the capitals in the path, and the link itself: /Products/ and /products/ can be different pages.

Check: a 4xx code points at the request, and the path is the part of the request most likely to be wrong.

Worked example 9

A sign-in page answers 429 after a learner presses Sign in fifteen times in a minute with a wrong password. Explain the code and why the server does this.

What we have: a 429 status after many quick tries

What we need: the meaning and the reason

The plan: read the family, then the code's meaning, then think of who would send so many requests

  1. Family 4: something about the request, here how many there are.
  2. 429 Too Many Requests: the server limits how often one person may try.
  3. Someone trying thousands of passwords would send exactly this pattern, so servers slow it down; this is called rate limiting, and the Security node covers it.

Too Many Requests: the server's rate limit protects accounts from password guessing; wait, then try once with the right password.

Check: the code is a client error, and the fix is on the client's side: fewer, slower requests.

When you are stuck: a status code you do not know

Read the first digit: 2 worked, 3 look elsewhere, 4 your request, 5 the server.

Look it up in the atlas table or on MDN, which has a page for every code.

For 4xx, check the address, the sign-in and the form; for 5xx, the problem is on the server, so check its logs if it is yours.

Your turn

console.log(Math.floor(301 / 100), Math.floor(429 / 100));
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
3 4
  1. 301 divided by 100 is 3.01, rounded down to 3.
  2. 429 divided by 100 is 4.29, rounded down to 4.

It prints 3 4: a redirection and a client error.

Which family of codes means the server itself failed?Tap to reveal
  1. The stove broke.

The 5xx family.

You are signed in, and a page answers 403. Will signing in again help?Tap to reveal
  1. 403 means the server knows who you are.

No: 403 means you are not allowed, whoever you are signed in as.

Did you know?

418 I'm a teapot

On 1 April 1998, as an April Fools' joke, a document in the internet's standards series described a protocol for controlling coffee pots. It said that any attempt to brew coffee with a teapot should give the error 418 I'm a teapot. In 2017 there was a call to remove 418 from tools such as Node.js. Programmers protested, the tools kept it, and the code was reserved, so no official status will take its number.

Why it fits here: A status code is three digits with a meaning, as this topic shows. 418 is the one whose meaning was a joke from the start.

Sources: RFC 2324: Hyper Text Coffee Pot Control Protocol; Wikipedia: Hyper Text Coffee Pot Control Protocol

451, a code named after a novel

In February 2016 a new status code joined HTTP: 451 Unavailable For Legal Reasons, for a page that cannot be shown because of the law, such as a page censored by a government. Its number refers to Ray Bradbury's 1953 novel Fahrenheit 451, in which books are outlawed. The standard that defines it ends its thanks with a short line: Thanks also to Ray Bradbury.

Why it fits here: A 4xx code means the request cannot be served as asked. 451 also says why: the law, and not a mistake.

Sources: RFC 7725: An HTTP Status Code to Report Legal Obstacles; Wikipedia: HTTP 451

In one line

A status code's first digit is its family: 2 worked, 3 look elsewhere, 4 the request is wrong, 5 the server failed; 200, 301, 404 and 500 are the ones you will meet most.

Watching it happen, and keeping it private

At a glance

One page is rarely one request. Its HTML names the styles, scripts, pictures and fonts it needs, and the browser asks for each of them, often dozens at once. The Network tab of the browser's developer tools shows every request as a row, with its status, type, size and time. A failing file shows in red, with its code.

With plain HTTP, any machine on the way could read or change the conversation. HTTPS seals it with TLS, and a certificate from a certificate authority proves that the site really owns its name. It does not prove that the owner is honest.

Take a guess: A site shows HTTPS in its address: does that prove the people who run it are honest?

One page is rarely one request. The first response, the page's HTML, names other things the page needs: its styles, its scripts, its pictures, its fonts. The browser asks for each of them, often dozens, many at the same time. The browser's developer tools let you watch every one.

The Network tab

Open the developer tools (F12, or Ctrl + Shift + I; Cmd + Option + I on a Mac) and choose the Network tab, next to the Console of Learning to learn. Then reload the page. Each request appears as a row.

ColumnWhat it shows
Namethe file asked for, the last part of its path
Statusthe status code: 200, 304, 404, and so on
Typewhat kind of thing it is: document, stylesheet, script, image, font
Sizehow much was downloaded, or that it came from the browser's saved copy
Timehow long it took

Click a row to see the request and the response in full: the method, every header in both directions, and the body. Everything this lesson described is there, live, for any site you visit.

Finding a failing request

When part of a page does not load, the Network tab often shows it in red, with a 404 or a 5xx status. That one row tells you which file failed and whose side the problem is on, before you read a single line of code.

HTTPS: the sealed envelope

On the way between your laptop and a site, a request passes through many machines: your Wi-Fi router, your internet provider, the networks in between. With plain HTTP, any of them could read it, or change it. That includes passwords typed into a form.

HTTPS

HTTP inside an encrypted connection made with TLS (Transport Layer Security). Only your browser and the site can read what travels between them, and nobody in the middle can change it without the change being detected.

HTTPS also proves who you are talking to. The site shows a certificate, signed by a trusted company called a certificate authority, that says this server really is study.rohannetworks.com. If the certificate does not match the name, the browser shows a full-page warning instead of the site.

Chrome marks pages that use plain HTTP as Not secure, in the address bar. And a page that arrived over HTTPS is not allowed to load scripts over plain HTTP: browsers block that, because one unsealed script could change the whole page.

const page = new URL("https://study.rohannetworks.com/tech/");
const picture = new URL("http://example.com/logo.png");
console.log("page sealed:", page.protocol === "https:");
console.log("picture sealed:", picture.protocol === "https:");
page sealed: true
picture sealed: false

A check like this is how a site's own tests catch an unsealed address before it ships: compare each address's scheme with "https:".

A common mistake

Thinking HTTPS makes a site trustworthy. It proves you reached the real owner of the name and that nobody read the conversation on the way. It says nothing about whether the owner is honest: a fraud site can have HTTPS too. Check the name itself, carefully, before typing a password.

Worked example 10

A message says "Your parcel is held, pay ₹25 here: https://indiapost-delivery-help.example/pay" (a made-up name, on the .example ending that is kept for examples). Suppose the page has HTTPS. Is it safe to pay?

What we have: an HTTPS link with a name that looks official

What we need: a decision based on what HTTPS does and does not prove

The plan: read the host, and recall what a certificate proves

const u = new URL("https://indiapost-delivery-help.example/pay");
console.log(u.hostname);
console.log(u.hostname.endsWith("indiapost.gov.in"));
indiapost-delivery-help.example
false
  1. HTTPS proves only that the page belongs to whoever owns indiapost-delivery-help.example.
  2. India Post's own site is under indiapost.gov.in, and this host is not.
  3. A name built from familiar words is the oldest trick there is.

Do not pay: the padlock is real, but the name is not India Post's.

Check: the host is the part that matters, and the check with endsWith shows it is not under the official domain.

Worked example 11

A page loads, but its logo does not. In the Network tab, the logo's row shows status 404. What does that tell you, and where do you look?

What we have: one failing request among many

What we need: whose problem it is, and the next step

The plan: read the family of the status, then the request's path

  1. 404 is a client error: the server is working, but nothing is at that address.
  2. Click the row and read the request's path: is the file name, a folder or a capital letter wrong?
  3. Compare with where the logo really is on the server.

The page asks for the logo at a wrong address; fix the path the page uses.

Check: a 404 says the address is wrong, not the server, so the fix is in the page's own HTML, which the next lesson reads.

When you are stuck: the Network tab

Open it before reloading: it records only what happens while it is open.

Type a word into its filter box to show only matching rows, or choose a type such as Img or JS.

Click a row and read its Headers part: the request first, then the response.

Your turn

Which tab of the developer tools lists every request a page makes?Tap to reveal
  1. It is next to the Console.

The Network tab.

const u = new URL("http://shop.example.com/login");
console.log(u.protocol === "https:");
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
false
  1. The scheme is http:, without the S.

It prints false: this sign-in page is not sealed.

Name the two things HTTPS gives you.Tap to reveal
  1. One is about privacy, one is about identity.

A sealed conversation (nobody in the middle can read or change it) and proof of the site's name (the certificate).

Did you know?

The lock that people misread

For years, browsers showed a small lock beside the address of a site that used HTTPS. Research by Google in 2021 found that only 11% of study participants understood exactly what the lock meant: many took it as a sign that a site could be trusted. Yet nearly all phishing sites use HTTPS too. So from Chrome 117, in 2023, the lock gave way to a new icon called tune, which carries no promise of trust.

Why it fits here: HTTPS seals the conversation and proves a site's name, but it says nothing about the owner's honesty, which is what the lock was mistaken for.

Sources: Help Net Security: Google Chrome will lose the lock icon for HTTPS-secured sites; TechSpot: Google is replacing Chrome's lock icon because it's confusing

Free certificates for every site

To use HTTPS, a site needs a certificate from a certificate authority. Let's Encrypt, brought to you by the nonprofit Internet Security Research Group, gives them away: it is a free, automated and open certificate authority. It launched on 12 April 2016. Anyone who owns a domain name can get a trusted certificate from it at zero cost, and software on the server can renew it by itself.

Why it fits here: The sealed envelope of this topic needs such a certificate, and a free one means that even a small site can have it.

Sources: Let's Encrypt: About; Let's Encrypt: Stats; Wikipedia: Let's Encrypt

In one line

The Network tab shows every request a page makes, with its status, type, size and time; HTTPS seals the conversation and proves the site's name, but not that its owner is honest.

Where it is used

Everything in this lesson happens every time anyone opens any page, in any browser, app or server. Here is where each piece shows up in a developer's work.

What you learnedWhere it is usedA real example
the parts of a URLlinks, routing in web apps, sharing searchesa train search page puts the stations and date in the query, so that the link to a search can be shared on WhatsApp
the URL valuereading and building addresses in codea shop's code reads the size and quantity from the query with searchParams.get
DNSputting a site online, moving it, adding subdomainspointing study.rohannetworks.com at Cloudflare Pages, and files at a second subdomain (the cloud step)
TTLplanning a move between serverslowering a record's TTL a day before a move, so that the change spreads in minutes
localhost and portsevery developer's own laptoprunning a site at http://localhost:4321 while building it, and a server at port 3000 beside it (the Node.js step)
requests and responsesevery API and every web pagea mobile app sends a POST with an order and reads the 201 Created that comes back
status codesdebugging, monitoring, search enginesa monitoring tool sends an alert when more than 1 in 100 answers is a 5xx
the Network tabfinding why part of a page fails or is slowa picture's row shows 404, or one script takes 3 seconds and holds up the page
HTTPS and certificatesevery site with a form, a sign-in or a paymenta certificate renews itself automatically every few months on Cloudflare

Mistakes and debugging

These are the slips people make with addresses and requests, and the fix for each.

1. An address without its scheme

const u = new URL("www.example.com/menu");
Uncaught TypeError: Failed to construct 'URL': Invalid URL
    at line 1

The fix: start every address in code with its scheme: https://www.example.com/menu.

2. Treating query values as numbers

const u = new URL("https://shop.example.com/cart?qty=2");
console.log(u.searchParams.get("qty") + 1);
21

Everything in an address is text, so + joins. The fix: Number(u.searchParams.get("qty")) + 1 is 3.

3. Spaces in an address

const u = new URL("https://example.com/search?city=New Delhi");
console.log(u.search);
?city=New%20Delhi

A space cannot travel in an address, so the URL value writes it as %20, the space's number. This is called percent-encoding. Reading it back with searchParams.get gives New Delhi again, so let the URL value do the encoding and decoding instead of writing %20 by hand.

4. Blaming the wrong side

A 4xx code means look at the request; a 5xx means look at the server. The fix: read the first digit before anything else, and start on the side it points to.

5. Trusting the padlock alone

The fix: HTTPS proves the name, not the honesty. Read the host itself before typing a password or paying.

6. Forgetting the browser's saved copies

A change on the server does not show up, because the browser reused its saved copy, its cache. The fix: in the Network tab, tick Disable cache while the developer tools are open, and reload.

The debugging corner: follow the request

When a page misbehaves, follow one request from start to end: is the address right (the URL), does the name resolve (DNS), what status came back, and what is in the body? Each step either shows the slip or rules out a whole layer.

Quick card

The lesson on one card.

Part of a URLExampleRead it with
schemehttps:u.protocol
hoststudy.rohannetworks.comu.hostname
port4321 (empty means the usual one)u.port
path/tech/atlas/u.pathname
query?q=joinu.search, u.searchParams.get("q")
fragment#rows (never sent to the server)u.hash

The lesson in code

const u = new URL("https://study.rohannetworks.com/tech/atlas/?q=join#rows");
console.log(u.hostname, u.pathname, u.searchParams.get("q"), u.hash);
console.log("family of 404:", Math.floor(404 / 100));
study.rohannetworks.com /tech/atlas/ join #rows
family of 404: 4
First digitFamily
2it worked
3look somewhere else
4the request is wrong
5the server failed

The journey of a page: the URL is read, and DNS turns the host into an IP address. The browser sends a request (method, path, headers), and the server answers (status, headers, body). Then the page asks for its other files. HTTPS seals every step.

The story: Every step of the way

You trace the journey step by step. The panel's address names the tower it wants. The Directory Office turns that name into the tower's number. A courier carries the request to that number, sealed in an envelope no one on the way can open. The harbour office's tower answers with the page, and the courier brings it back to your glass.

Tobin listens to the end, then nods once. "Every panel in the city works that way, even the ones that look like magic," he says. "Tomorrow, at the Hall, you learn to build one."

Reagents gathered: URL, IP address, DNS, HTTP, HTTPS.

Sources