Free preview
How the web works
Reading · 12 min
Before you write a single line of code, it helps to know what actually happens when you type an address into a browser and press Enter. Once you understand this, a lot of things that look like magic later in the course will make sense.
Three things working together
Every time you visit a website, three things cooperate:
- The browser (Chrome, Firefox, Safari, Edge) runs on your device. It asks for pages and then draws them on your screen.
- The server is a computer somewhere else that stores the website's files and sends them when asked.
- The network (the internet) carries the request from your browser to the server and carries the answer back.
The browser and the server talk using a set of rules called HTTP (Hypertext Transfer Protocol). The secure version, HTTPS, encrypts the conversation so nobody in between can read or change it. That is what the padlock next to the address means.
What happens when you press Enter
- 1
You type an address
For example
https://example.com/about. Thehttps://part is the protocol,example.comis the domain name and/aboutis the path to the page you want. - 2
The browser finds the server
Computers on the internet are found by numeric IP addresses, not names. The browser asks the DNS (Domain Name System), which works like the internet's phone book, to turn
example.cominto an IP address such as93.184.215.14. - 3
The browser sends a request
It connects to that server and sends an HTTP request that says, in effect, "please send me
/about". - 4
The server answers
The server sends back a response: a status code (
200means OK,404means not found) and the content, usually an HTML file. - 5
The browser builds the page
The browser reads the HTML, notices it also needs CSS files, images and maybe JavaScript, and requests each of those too. Then it combines them and draws the page.
The three languages of the web
| Language | Job | Think of it as |
|---|---|---|
| HTML | The content and its structure: headings, paragraphs, images, links | The skeleton |
| CSS | How it looks: colours, fonts, spacing, layout | The clothes |
| JavaScript | How it behaves: menus that open, forms that check themselves | The muscles |
This course is about the first two. HTML and CSS are not "programming" in the strict sense, because they describe things rather than give step-by-step instructions, but they are the foundation of every website, and every web developer uses them every day.
Static and dynamic sites
A static site is a set of files that are sent exactly as they are stored. A dynamic site builds pages on the server when you ask, for example to show your own account. Both send HTML to the browser in the end. The sites you build in this course are static, which means they are fast, cheap (often free) to host and a great place to start.
Try it
Trace a visit
Open any website you use often. Look at its address and write down the protocol, the domain name and the path. Then open its page source and find the <title> line. What does it say, and where do you see that text in the browser?
Show a hint
The title usually appears on the browser tab, not on the page itself.
Show a worked answer
For https://www.bbc.com/news the protocol is https, the domain is www.bbc.com and the path is /news. The text inside <title>…</title> is what you see on the tab and in search results.
Like this lesson?
HTML & CSS Fundamentals has 21 lessons with exercises, quizzes and a final project.