RajScape
← Back to Blog
AP CSPNovember 3, 20259 min read

How the Web Works: HTTP, HTML, and the Request-Response Model

The World Wide Web is one of the most important inventions of the 20th century. Every time you open a browser and visit a website, you are using the web. But have you ever wondered what actually happens between typing a URL and seeing a webpage? Understanding how the web works is essential for the AP CSP exam and for anyone who wants to build websites or web applications. In this post, we will explore the request-response model, HTTP, HTML, and the other technologies that make the web function.

The Client-Server Model

The web is built on the client-server model. The client is your web browser (Chrome, Firefox, Safari, etc.), and the server is a computer that stores website files and sends them to clients upon request. When you visit a website, your browser sends a request to the server, and the server responds by sending the requested files back to your browser. Your browser then renders the files and displays the webpage.

This model is fundamentally a conversation between two computers. The client asks for something, and the server provides it. The client does not know how the server stores or generates the content; it only knows how to request it. The server does not know what the client will do with the content; it only knows how to send it. This separation of concerns is a powerful form of abstraction that allows clients and servers to evolve independently.

HTTP: The Language of the Web

HTTP (Hypertext Transfer Protocol) is the protocol that governs communication between clients and servers on the web. A protocol is a set of rules that define how data is formatted and transmitted. HTTP defines the format of requests and responses, the methods available (GET, POST, PUT, DELETE, etc.), the status codes that indicate success or failure, and the headers that provide additional information.

An HTTP request has several components: a method (usually GET for retrieving data or POST for sending data), a URL (the address of the resource), headers (metadata about the request), and optionally a body (data being sent to the server). An HTTP response has a status code (like 200 for success or 404 for not found), headers, and a body (the requested resource).

HTML: The Structure of Webpages

HTML (Hypertext Markup Language) is the standard language for creating webpages. HTML uses tags to define the structure and content of a webpage. Tags are enclosed in angle brackets and usually come in pairs: an opening tag and a closing tag. For example, <p>Hello</p> defines a paragraph containing the text "Hello."

HTML tags form a tree structure called the DOM (Document Object Model). The <html> tag is the root of the tree. Inside it are the <head> tag (containing metadata like the title and links to CSS and JavaScript files) and the <body> tag (containing the visible content of the webpage). Inside the body are tags for headings, paragraphs, links, images, lists, and many other elements.

CSS: The Style of Webpages

CSS (Cascading Style Sheets) controls the visual presentation of HTML elements. While HTML defines the structure, CSS defines the appearance: colors, fonts, spacing, layout, and responsive design. CSS uses selectors to target HTML elements and rules to define their styles. For example, p { color: blue; font-size: 16px; } makes all paragraphs blue with a font size of 16 pixels.

CSS can be applied in three ways: inline (using the style attribute on an element), internal (using a <style> tag in the HTML head), or external (linking to a separate CSS file). External stylesheets are the preferred approach because they separate content from presentation, making code easier to maintain.

JavaScript: The Behavior of Webpages

JavaScript is the programming language of the web. While HTML provides structure and CSS provides style, JavaScript provides behavior. JavaScript can respond to user events (like clicks and keystrokes), modify the DOM, send requests to servers, validate form input, create animations, and much more. JavaScript runs in the browser, not on the server, which means it executes on the user's device.

Modern web development uses JavaScript extensively. Single-page applications (SPAs) are built entirely with JavaScript and dynamically update the page without full reloads. Frameworks like React, Vue, and Angular provide powerful tools for building complex user interfaces with JavaScript. Server-side JavaScript with Node.js allows JavaScript to run on the server as well.

The Full Journey of a Webpage

When you type a URL into your browser, the following happens: First, the browser performs a DNS lookup to find the IP address of the server. Then it establishes a TCP connection to the server. Next, it sends an HTTP request for the HTML file. The server responds with the HTML content. The browser parses the HTML and discovers references to CSS files, JavaScript files, and images. It sends additional HTTP requests for each of these resources. As each resource arrives, the browser builds the DOM, applies CSS styles, and executes JavaScript. Finally, the browser renders the complete webpage on your screen.

This entire process, from typing the URL to seeing the webpage, typically takes less than a second. The speed is a testament to the efficiency of the protocols and technologies that make up the web. Understanding this process gives you a deeper appreciation for the incredible infrastructure that powers the modern internet.

The Web on the AP CSP Exam

The AP CSP curriculum covers the web as part of the Big Idea on the Internet. You should understand the client-server model, HTTP, HTML, CSS, and JavaScript at a high level. You should be able to explain how a webpage is loaded, what role each technology plays, and how the different components interact. Understanding the web is not just important for the exam; it is essential knowledge for any modern programmer, as web technologies are used in almost every area of computing.