What Actually Happens When You Open a Website?
10 minBeginnerHTML · CSS · JS
In this lesson
- ▸Describe what a browser, a server and a request are
- ▸Know that a web page starts life as plain text files: HTML, CSS and JavaScript
- ▸Edit an HTML file and see the browser render your change
The big idea
A website is a set of text files. Your browser asks a server for them, then reads the text and draws the page.
When you type an address like wancode.my and press Enter, a lot happens in under a second. The good news: you only need four ideas to understand it.
- Browser
- The app you're using right now (Chrome, Safari, Firefox…). It requests files and turns them into a page.
- Server
- A computer somewhere on the internet that stores a website's files and sends them when asked.
- Request / Response
- The browser sends a request ("please send me this page"). The server sends back a response (the file).
- HTML · CSS · JavaScript
- HTML is the content and structure. CSS is the look. JavaScript is the behaviour.
The page is just text
Here is a complete web page. The words inside angle brackets — like <h1> — are tags. They tell the browser what each piece of text is: a heading, a paragraph, the page title.
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello, web!</h1>
</body>
</html><head>holds information about the page. The<title>appears on the browser tab, not on the page itself.<body>holds everything you can see.- The
<link>tag in the editor's file pulls instyle.css, which controls colours and spacing.
Nothing here is magic. If you can edit a text file, you can edit a website. Try it in the editor — the preview redraws as you type.
In index.html, change the text inside <h1> so it says hello from you (for example Hello, I'm Aina!). Then change the <title> to anything other than My Page.
Checks
- The heading text has changed
- The page title has changed
Check understanding
What you learned
- ✓A browser requests files from a server and renders them.
- ✓Web pages are text: HTML for structure, CSS for style, JavaScript for behaviour.
- ✓Tags like
<h1>and<p>label what each piece of content is.
Console output from your code appears here.