Lesson 1 of 23

In progress

Course progress

HTML and CSS

How the web actually works

Follow a URL from browser to server and back, and learn why a page you open from disk behaves differently from one on the web.

Before writing a page, it helps to know who is doing what. Almost every confusing beginner problem — a broken image, a stylesheet that will not load, a form that goes nowhere — is easier once you can picture the request and the response.

What you will learn

  • Follow the path from a typed URL to a rendered page.
  • Tell the parts of a URL apart.
  • Explain why file:// and http:// are not the same place.

Two computers and a conversation

When you type an address, your browser asks a name server what IP address belongs to that domain. It then opens a connection to that address and sends a request: "give me this path". The server answers with a status code and a body, usually HTML.

The browser reads the HTML, discovers stylesheets, images and scripts, and requests those too. Each is a separate request with its own response. A page that "loads slowly" is usually waiting on one of those extra requests, not on the HTML itself.

The server can be a large platform or a folder of files. A static server simply returns the file that matches the path. A dynamic server runs code first, then builds HTML from a database. Both end with the same thing arriving at the browser: text.

The parts of a URL

https://tutorials.in/tutorials/python/lists?ref=home#examples breaks down into:

  • https — the protocol, which decides how the conversation is encrypted.
  • tutorials.in — the host, resolved to an IP address.
  • /tutorials/python/lists — the path, which the server maps to a file or a route.
  • ?ref=home — the query string, data the server may use.
  • #examples — the fragment, handled by the browser alone to scroll to an element.

The fragment never reaches the server. That is why an anchor link works instantly and why a server cannot log which section someone read.

HTML is the structure, not the design

HTML describes what things are: a heading, a paragraph, a list, a link. CSS decides how they look. JavaScript decides how they behave. Keeping those jobs separate is not fussiness; it is what lets the same page work on a phone, in a screen reader and in a search engine.

A page with no CSS should still be readable in a sensible order. If it is not, the HTML is doing the wrong job, and no amount of styling will fix the underlying structure.

Why file:// is different

Opening a saved .html file from your desktop uses the file:// protocol. There is no server, so there is no request, no status code and no path routing.

That difference explains three common surprises:

  • A page that works on your computer may break when uploaded, because paths that resolved locally do not exist on the server.
  • Some browser features, including many that involve loading data, are restricted for local files.
  • Links to /about mean the root of your hard drive locally, but the root of the site online.

Use a local server for anything beyond a single page. A code editor’s preview, or python3 -m http.server in the folder, gives you http://localhost:8000 and behaviour much closer to production.

Looking behind the page

Every browser can show what arrived. View Source shows the HTML the server sent; the Elements panel shows the page after the browser fixed your markup and JavaScript changed it. They are not the same, and knowing which one you are looking at saves hours.

The Network panel lists every request, its status and its size. A missing stylesheet is a red 404 in that list, not a mystery.

HTML
Editable. Runs in your browser.





Press Run to see the output.

Run that and you have the whole model in one file: text in, structure out, and a browser deciding how to draw it.

Testing a site by double-clicking the HTML file and then wondering why fetch or a module script fails is the classic file:// trap. Serve the folder over HTTP before debugging anything that loads another file.

Take the URL https://example.com/blog/post-1?utm_source=newsletter#comments and write down the protocol, host, path, query string and fragment. Then explain which part the server never sees.

Show solution

Protocol: https. Host: example.com. Path: /blog/post-1. Query: utm_source=newsletter. Fragment: comments.

The fragment is never sent to the server. The browser uses it after the page loads to scroll to the element with that id.

Recap

  • A page is HTML requested from a server and rendered by a browser, plus separate requests for CSS, images and scripts.
  • A URL names the protocol, host, path, query and fragment; the fragment stays in the browser.
  • HTML carries structure, CSS carries presentation, and file:// is not a server.

Next, you will write a complete HTML document and open it in a browser.

Do I need to learn networking to build pages?
No. You need the request-and-response model and the ability to read the Network panel. DNS, TLS and caching details become useful later, when you are tuning a real site.
What is localhost?
It is the address of your own computer, usually `127.0.0.1`. A local server makes your folder available at `http://localhost:PORT`, which behaves like a real server for paths and file loading.

Full syllabus

Progress is saved in this browser only. No account, no email.

Admin

About the author

Admin

Instructor and technical writer at tutorials.in

Writes beginner lessons for tutorials.in. Each lesson is checked against the language or tool documentation, and examples are run before publishing.

Reviewed by the editorial team before publishing. Last updated November 16, 2026.