How a web page reaches you
Browsers and servers
Follow the simple request and response exchange between a browser and a web server before the browser renders an HTML page.
5 minute lesson
A browser is an HTTP client. You give it a URL, and it makes a request on your behalf.
The server receives that request and decides what to send back. It might read an HTML file from disk. It might generate HTML using data from a database. The browser does not need to know which approach the server used.
A simplified exchange looks like this:
GET /about/ HTTP/1.1
Host: example.com
The server could answer:
HTTP/1.1 200 OK
Content-Type: text/html
<h1>About us</h1>
The browser reads the Content-Type header and knows the response contains HTML. It parses the markup and turns it into a document on the screen.
This distinction is useful:
- the server sends HTML
- the browser interprets HTML
The browser also provides default styles. This is why a heading appears larger than a paragraph even before you write any CSS.
HTML is forgiving. Browsers try hard to display imperfect documents. That helps the Web keep working, but it also means a page that looks correct can still contain mistakes. Later we’ll use validation tools to find them.
Lesson completed