MGU Computer Science Series — Web Development: HTML, CSS, and JavaScript
Part I: Foundations of the Web
Internet · Web · Clients · Servers · URLs · Protocols
Chapter 2 of 30
2
MGU Computer Science Series  ·  Web Development: HTML, CSS, and JavaScript  ·  Library Textbook Edition

Chapter 2:
How the Web Works

Clients, servers, browsers, URLs, requests, responses, and the open standards that turn billions of separate devices into one connected system

■ Part I of VII ■

■ 10 Sections  •  Chapter 2 of 30 ■

Second chapter — builds on Chapter 1 only; no prior web development experience required

Chapter Introduction and Learning Objectives

Before writing a single line of HTML, you need a clear picture of the system your code will live inside. Open any browser and visit any website, and an enormous amount of coordinated activity happens in a fraction of a second — computers find each other across the planet, exchange carefully formatted messages, and assemble files into the page you see on screen. Most users never think about any of this. Web developers cannot afford that luxury.

This chapter explains what happens when someone types a web address into a browser, what a server actually does, how files travel across the internet, and why that journey matters for every website you build. Understanding the web as a system will help you write better code, diagnose problems more quickly, and make decisions that real web developers think about every day.

Opening Question

You type a web address into your browser and press enter. Less than a second later, a complete page appears — text, images, styling, and interactive elements all in place. Between the moment you pressed enter and the moment the page appeared, your request traveled to a computer you have probably never seen, in a building you cannot locate, and a precise, standardized conversation took place between two machines that had never spoken to each other before. What exactly happened in that second? By the end of this chapter, you will be able to trace that journey step by step.

10Sections
12Objectives
24Key Terms
30Total Chapters

Learning Objectives

By the end of this chapter, you should be able to:

  1. 1Distinguish between the internet and the World Wide Web, and name one internet service that is not part of the web.
  2. 2Describe the client-server model and explain the role a browser plays within it.
  3. 3Explain the main responsibilities a browser performs when it loads a page.
  4. 4Describe what a web server does, and distinguish a static server from a dynamic server.
  5. 5Identify the five components of a URL and explain the purpose of each.
  6. 6Describe the request-response cycle and interpret common HTTP status codes.
  7. 7Explain the difference between HTTP and HTTPS and why published websites should always use HTTPS.
  8. 8Explain how DNS translates a domain name into an IP address.
  9. 9Distinguish between a domain name and web hosting, and describe at least two types of hosting.
  10. 10Explain the difference between opening a file with file:// and serving it through a local development server.
  11. 11Explain how open web standards allow the same HTML, CSS, and JavaScript to work across different browsers and devices.
  12. 12Trace the full sequence of events that occurs when a browser loads a web page, from typing a URL to final rendering.

Sections at a Glance

Sections 2.1 – 2.3
The Big Picture: Internet, Web, and Browsers
Internet vs. Web · Clients and Servers · Browsers

The Internet and the Web Are Not the Same

Most people use the words internet and web interchangeably. In everyday conversation that is usually fine, but for a web developer the distinction matters.

The internet is a global network of interconnected computers. It is the physical and logical infrastructure: fiber-optic cables running under oceans, wireless signals, routers directing traffic, and agreed-upon rules that allow billions of devices to communicate. The internet carries many different kinds of traffic — email, file transfers, video calls, messaging apps, and more.

The World Wide Web — usually just called the web — is one system that runs on top of the internet. It is a collection of interconnected documents and resources that you access through a browser. The web was invented by Tim Berners-Lee in 1989 as a way to share and link research documents. It grew from a handful of pages into billions of websites.

A Key Analogy

Think of it this way: the internet is the highway system. The web is one category of traffic that travels on those highways — specifically, the traffic that browsers read, display, and link together. When you write HTML, CSS, and JavaScript files, you are creating content for the web. Those files will travel across the internet to reach users, but the internet itself does not care what is inside them. The browser is the tool that gives those files their meaning.

Other Systems That Run on the Internet but Are Not the Web

Service
Email
Uses protocols called SMTP, IMAP, and POP3 — entirely separate from the web's HTTP protocol.
Service
File Transfers
Uses FTP (File Transfer Protocol) to move files directly between computers, without a browser involved.
Service
Video Streaming Applications
Many streaming apps use delivery methods built for continuous media rather than for linked, browsable documents.
Service
Online Games
Games with direct network connections often use custom protocols designed for fast, real-time data exchange.
Service
Messaging Apps
Many messaging apps run their own protocols rather than the web's document-and-link model.

Each of these uses the internet as its transport layer, but none of them is part of the web in the technical sense. They do not use the same protocols, document formats, or browser-based experience that web development produces. When you build a website, you are building specifically for the web — and that means HTML, CSS, JavaScript, and the protocols this chapter describes.

Clients and Servers

The web runs on a relationship between two kinds of computers: clients and servers.

A client is a device that requests resources. When you open a browser and visit a website, your computer or phone is acting as a client. It sends out a request saying, in effect, "please send me this page." The browser is the program on the client that makes those requests and displays the results.

A server is a computer that listens for requests and sends back responses. When a server receives your request for a web page, it finds the relevant files and sends them back across the internet to your browser.

The Client-Server Model
Client (Your Browser)          Server (Web Host)
        |                              |
        |  -- Request: "Give me        |
        |     index.html" -----------> |
        |                              |
        |  <-- Response: Here are      |
        |      the files (HTML, CSS,   |
        |      JavaScript, images) --- |
        |                              |

This back-and-forth is called the client-server model. Almost everything on the web follows this pattern.

Point 1
Servers Run Continuously
A web server is not a laptop someone turns on and off. It runs specialized software designed to stay online twenty-four hours a day and respond to thousands of requests per second.
Point 2
Roles, Not Machines
Servers and clients are roles, not fixed machines. A single computer can act as a server for one purpose and a client for another — your own computer can be both at once during development.
Point 3
Location Is Invisible to Clients
Clients do not need to know where a server is physically located. The internet handles the routing — your browser never needs to know which country, city, or data center it is talking to.
Point 4
Separation Matters for Security
Code you write for a web page runs on the client, inside the visitor's browser. Code that runs on a server is separate and controlled by the website owner. This distinction matters once you start working with user accounts and sensitive data.
Where You Stand Right Now

Remember that everything you write in HTML, CSS, and JavaScript in this course runs in the browser — on the client side. Server-side code, written in languages like Python, PHP, or Node.js, is a separate topic for later courses.

Browsers

A browser is a program that requests web pages, interprets the files it receives, and displays the result as a visual, interactive experience on your screen.

You are likely familiar with several browsers: Chrome, Firefox, Safari, Edge, and others. Each of these is a complex piece of software with many responsibilities:

  • Sending HTTP requests to servers
  • Receiving HTML, CSS, JavaScript, images, fonts, and other files
  • Parsing (reading and interpreting) HTML to build a page structure
  • Applying CSS rules to produce visual layout and styling
  • Executing JavaScript to handle interaction and dynamic behavior
  • Displaying the final result on screen
  • Managing security, privacy, history, bookmarks, and extensions

From a developer's perspective, the browser is your most important tool. It is where your code runs, where your users experience your work, and where you will spend a great deal of time inspecting, debugging, and testing.

How Browsers Interpret Your Code

When a browser receives an HTML file, it does not display the raw text. It reads the tags, builds an internal model of the page structure, downloads any linked CSS files and images, applies the styles, runs any JavaScript, and then renders the final visual result. This process happens very quickly — often in a fraction of a second.

Browser Differences

Different browsers can interpret the same HTML and CSS slightly differently. Modern browsers have become much more consistent than they were in earlier years, but differences still exist. Good web developers test their pages in multiple browsers to confirm they look and work correctly everywhere.

Every modern browser also includes a powerful set of inspection and debugging tools built directly into it — Chapter 4 is dedicated entirely to these developer tools, and you will use them constantly throughout this course.

Sections 2.4 – 2.6
The Mechanics: Servers, Addresses, and Communication
Web Servers · URLs · Requests and Responses

Web Servers

A web server is a computer — or more precisely, software running on a computer — that listens for incoming requests over the internet and responds by sending files back to clients.

The most common web server software includes Apache, Nginx, and Microsoft IIS, though there are many others. When you host a website, you are either running web server software on a computer you control or paying a hosting company to run it on computers they control.

Process
What a web server does when it receives a request
  • Step 1It receives a request for a specific file or resource (such as index.html).
  • Step 2It locates that file in its file system.
  • Step 3It sends the file back to the client along with information about the file and the result of the request.
  • Step 4The client (browser) receives the file and processes it.

Static Versus Dynamic Servers

TypeDescription
Static web serverSimply delivers files exactly as they are stored. When a browser asks for index.html, a static server sends back that file without modification. This course focuses on static files you write and serve directly.
Dynamic web serverCan generate files on the fly. When you log into a website and see your name on the page, that page was probably generated dynamically — the server retrieved your information from a database and inserted it into the HTML before sending it to your browser. Server-side development of this kind is beyond the scope of this course.
Local Development Servers

During development, you will often run a simple local web server on your own computer so that your browser can request files just as it would from a real server. This matters because some browser behaviors — particularly around JavaScript and file access — work differently when you open a file directly from your desktop compared to requesting it through a server. Chapter 3 discusses project setup, including local servers, in more detail.

URLs and Web Addresses

A URL (Uniform Resource Locator) is the address of a specific resource on the web. When you type an address into your browser's address bar, you are typing a URL. When you click a link, that link contains a URL. When your HTML references an image or a stylesheet, those references are URLs too.

Understanding URL structure is essential for web development, both for linking pages correctly and for understanding how the web organizes resources.

The Structure of a URL
https://www.example.com/about/team.html?sort=name#contact
  |          |               |              |         |
scheme     host            path          query     fragment
Anatomy of a URL
Five components, five jobs
  • SchemeTells the browser what communication protocol to use. For web pages this is almost always http or https. The s in https means the connection is encrypted (see Section 2.7).
  • HostIdentifies which server to contact — the human-readable name for a server's address. www.example.com is a hostname. www is an optional subdomain; sites also use subdomains like blog.example.com or shop.example.com.
  • PathTells the server which specific resource is being requested. /about/team.html means "look in the about folder for a file called team.html." A path ending in just / typically requests the default file in that directory, usually index.html.
  • Query stringAn optional set of parameters beginning with ?, containing key-value pairs separated by &. In ?sort=name, the key is sort and the value is name. You see query strings with search engines, filters, and forms that use the GET method.
  • FragmentAn optional identifier beginning with # that refers to a specific location within a page. Fragments are handled entirely by the browser and are never sent to the server.

You will use URLs constantly when writing HTML — to link pages together, to reference images, to load stylesheets and scripts. Chapter 3 covers the difference between relative and absolute paths in detail, since this is a common source of beginner errors.

Requests and Responses

Every interaction between a browser and a web server follows the same fundamental pattern: the browser sends a request and the server sends back a response. This is called the request-response cycle.

Outgoing
A Request Contains
A method — usually GET to retrieve a resource, or POST to submit data — the URL of the resource, headers describing the browser and what it can accept, and sometimes a body of data sent to the server.
Incoming
A Response Contains
A status code indicating the result, headers with metadata about the response such as content type, and a body — the actual HTML file, image, CSS file, or whatever was requested.

Status Codes

CodeMeaning
200 OKThe request succeeded and the content is in the response body
301 Moved PermanentlyThe resource has permanently moved to a new URL
302 FoundThe resource is temporarily at a different URL
304 Not ModifiedThe browser's cached version is still current (no new download needed)
400 Bad RequestThe request was malformed or invalid
403 ForbiddenThe server understood the request but refuses to fulfill it
404 Not FoundThe requested resource does not exist on the server
500 Internal Server ErrorThe server encountered an unexpected error
The 404 Error

The 404 error is familiar to almost every internet user. As a developer, you will cause 404 errors when you have broken links, mistyped file paths, or deleted files without updating the links pointing to them. Chapter 3 explains how to avoid these mistakes.

Loading a single web page usually involves many individual requests, not just one. When your browser receives the HTML file, it reads through it and discovers that the page also needs a CSS file, several image files, a JavaScript file, and perhaps some fonts. It sends separate requests for each of those resources. A typical web page may involve dozens or even hundreds of individual requests.

Why This Matters for Performance

Every request takes time, and the time adds up. Good web developers think about how many resources a page requires and how large those resources are.

Sections 2.7 – 2.10
Putting It Together: Security, Naming, and the Open System
HTTP and HTTPS · Domains and Hosting · Local vs. Published · A Connected System

HTTP and HTTPS

HTTP (HyperText Transfer Protocol) is the set of rules that governs how web browsers and servers communicate. It defines how requests are formatted, what responses look like, and how the conversation between client and server proceeds.

HTTP was designed in the early days of the web as a simple, readable protocol. An HTTP request is text — structured text, but human-readable. Over time, HTTP has evolved through several versions (HTTP/1.1, HTTP/2, HTTP/3), each improving speed and efficiency, but the fundamental request-response structure remains the same.

HTTPS (HTTP Secure) is HTTP with an added layer of encryption. When you use HTTPS, the data traveling between your browser and the server is encrypted so that anyone who intercepts it cannot read the contents.

Without Encryption

Without HTTPS, your requests and responses travel in plain text. Anyone monitoring the network — on public Wi-Fi, at an internet service provider, or anywhere along the route — could read exactly what you are sending and receiving, including passwords, personal information, and private messages.

Why HTTPS Matters for Developers

Reason 1
Browser Warnings
Modern browsers flag HTTP pages as "Not Secure" and warn users before they interact with forms.
Reason 2
Search Rankings
Search engines give preference in rankings to HTTPS sites.
Reason 3
Feature Access
Many browser features — including some JavaScript APIs and media capabilities — only work on HTTPS pages.
Reason 4
Developer Responsibility
As someone building public websites, you have a responsibility to protect your users' data.

When you publish a website, you should always use HTTPS. Hosting providers typically offer free HTTPS certificates through services like Let's Encrypt, making this accessible to everyone.

During Local Development

When you develop a website on your own computer, you will typically use http://localhost or http://127.0.0.1 — special addresses that refer to your own machine. These do not require HTTPS certificates because you are not sending data across the public internet. Once you publish your site publicly, switching to HTTPS is standard practice.

Domain Names and Hosting

When someone visits a website by typing a name like www.example.com, several layers of infrastructure work behind the scenes to connect that name to the right server.

Every device on the internet has a numerical address called an IP address (Internet Protocol address). A typical IPv4 address looks like 192.168.1.1 — four groups of numbers separated by dots. A newer format, IPv6, uses longer hexadecimal addresses. These numerical addresses are what computers actually use to route traffic.

Humans are not good at remembering strings of numbers. Domain names are human-readable names — like example.com or mgu.edu — that map to IP addresses.

DNS — The Internet's Address Book

The Domain Name System (DNS) translates human-readable domain names into the numerical IP addresses computers actually use. When you type www.example.com into your browser, your computer sends a query to a DNS server asking, "What is the IP address for this domain?" The DNS server responds with the IP address, and your browser can then connect to the right server. This lookup takes only milliseconds but is a necessary step every time you visit a new website. Your browser and operating system cache DNS results for a period of time so that repeated visits to the same site do not require repeated lookups.

Domain names are registered through companies called domain registrars. You pay an annual fee to reserve a name like yourproject.com. If you do not renew, the name becomes available to others.

Even if you own a domain name, you also need somewhere to store your website files. Web hosting is a service that keeps your files on a server connected to the internet around the clock, ready to respond to requests.

Type of HostingDescription
Shared hostingYour files share server resources with many other websites. Affordable and easy to set up. Good for small, low-traffic sites.
Static site hostingServices like GitHub Pages, Netlify, and Vercel are specifically designed for static HTML, CSS, and JavaScript sites. Many offer free plans. A good choice for the projects in this course.
Virtual private servers (VPS)More control and more power, but requires more technical knowledge.
Cloud hostingLarge-scale, highly configurable hosting from providers like AWS, Google Cloud, and Azure.

When you register a domain name and set up hosting, you configure the domain's DNS settings to point to your hosting provider's servers. This tells the internet: "When someone asks for yourdomain.com, send them to this server." For this course, you will primarily develop locally — Chapter 30 covers publishing options in detail.

Local Files and Published Websites

Understanding the difference between opening a file locally on your computer and loading a page through a web server will save you from confusion throughout this course.

When you double-click an HTML file on your desktop, your browser opens it using the file:// protocol instead of http:// or https://. The address in your browser bar will look something like:

A Local File Address
file:///Users/yourname/Desktop/my-project/index.html

Your browser can display the HTML, apply the CSS, and run some JavaScript this way. For early exercises and simple pages, this often works fine. However, opening files locally is not the same as serving them through a web server.

Real Differences with file://
  • Some JavaScript features do not work, particularly anything involving fetching external data or certain security-sensitive APIs.
  • Relative paths behave differently in some edge cases.
  • The experience does not match what your users will see when they visit your published site.
  • HTTPS features are unavailable entirely.
Use a Local Development Server Instead

For any project beyond simple exercises, you should use a local web server instead of opening files directly. Many code editors offer this feature as an extension — Visual Studio Code's popular "Live Server" extension serves your project files through http://localhost with a single click. When you run a local server, your browser's address bar shows something like http://localhost:5500/index.html, giving you a much more accurate preview of how your site will behave when published.

It is important to hold both in mind: your local development copy (which only you can see) and the published website (which anyone with the URL can see). Changes you make to your local files do not automatically appear on the published site. To update a published website, you need to transfer the changed files to the hosting server — Chapter 30 covers deployment workflows. During development, however, you will almost always be working locally: edit, save, reload the browser, and check your work, dozens or hundreds of times per session.

The Web as a Connected System

Pull back and look at the whole picture. The web is not just a collection of pages — it is a system of interconnected technologies, standards, and practices.

The web works because everyone follows agreed-upon standards. HTML, CSS, JavaScript, HTTP, and URLs are all defined by specifications maintained by standards bodies — primarily the World Wide Web Consortium (W3C) and the WHATWG (Web Hypertext Application Technology Working Group). These specifications describe precisely how browsers should interpret HTML tags, apply CSS rules, execute JavaScript, and handle HTTP requests.

Because of these standards, you can write an HTML file and have it work in Chrome, Firefox, Safari, and Edge — on Windows, macOS, iOS, Android, and Linux — without writing separate code for each combination. This interoperability is one of the web's most powerful features.

Full Sequence
How your code fits into the system
  • Step 1You write HTML, CSS, and JavaScript files on your computer.
  • Step 2You upload those files to a server connected to the internet.
  • Step 3A user types your URL or clicks a link pointing to your site.
  • Step 4Their browser sends an HTTP request to your server.
  • Step 5Your server sends back the HTML file.
  • Step 6The browser reads the HTML, discovers linked CSS and JavaScript files, and requests those too.
  • Step 7The browser builds the page structure from the HTML, applies styles from the CSS, and runs the JavaScript.
  • Step 8The user sees and interacts with your page.

Every step in that sequence depends on something from this chapter: protocols, servers, clients, URLs, requests, responses, domain names, and the browser's ability to interpret your files.

Unlike many software systems, the core technologies of the web are open and public. Anyone can read the HTML specification. Anyone can inspect the source code of any web page. Anyone can learn to build for the web without paying for proprietary tools or licenses. This openness is why the web grew so rapidly and why it remains such a powerful platform for sharing information and building applications.

Your Responsibility as a Developer

Because web pages are public — potentially seen by anyone, anywhere, on any device — web developers have real responsibilities. You are building for real users with different devices, different browsers, different connection speeds, different abilities, and different contexts. Accessibility, performance, security, and clarity are not optional extras. They are part of what makes a website good — and these responsibilities will come up repeatedly throughout this course, starting with the very first HTML you write.

Chapter Summary

Key Terms

browser
A program that requests web pages, interprets HTML, CSS, and JavaScript, and displays the result to the user.
client
A device or program that requests resources from a server. In web development, the browser acts as the client.
client-server model
The fundamental architecture of the web, in which clients send requests and servers send responses.
DNS (Domain Name System)
The system that translates human-readable domain names into numerical IP addresses.
domain name
A human-readable name, like example.com, that maps to the IP address of a server.
fragment identifier
The part of a URL beginning with # that refers to a specific location within a page.
hosting
A service that stores your website files on a server connected to the internet.
HTTP (HyperText Transfer Protocol)
The set of rules governing communication between browsers and web servers.
HTTPS (HTTP Secure)
HTTP with encryption added, protecting data in transit between browser and server.
IP address
A numerical address that uniquely identifies a device on the internet.
internet
The global network of interconnected computers; the infrastructure the web runs on top of.
localhost
A special hostname that refers to your own computer, used during local development.
path
The part of a URL that identifies which specific resource on a server is being requested.
query string
The optional part of a URL beginning with ? that passes additional parameters to the server.
request
A message sent from a client to a server asking for a resource or submitting data.
request-response cycle
The fundamental pattern of web communication: the browser sends a request and the server sends a response.
response
A message sent from a server back to a client, containing a status code and, usually, the requested content.
scheme
The first part of a URL identifying the protocol, such as http or https.
server
A computer or software that listens for requests and sends back responses.
static web server
A server that delivers files exactly as they are stored, without generating content dynamically.
status code
A three-digit number in an HTTP response indicating whether the request succeeded or failed.
URL (Uniform Resource Locator)
The address of a specific resource on the web.
web
The collection of interconnected documents and resources accessible through browsers using HTTP; runs on top of the internet.
web server software
Programs like Apache and Nginx that handle incoming HTTP requests and serve files in response.
ActivitiesClient-Server Diagram Practice

Study the diagram below, then answer the questions that follow.

Loading a Page, Step by Step
[User types: https://www.learningsite.edu/lessons/html-basics.html]
         |
         v
  [Your Browser]
         |
         | 1. DNS Lookup: "What is the IP for www.learningsite.edu?"
         v
    [DNS Server]
         |
         | 2. "The IP address is 203.0.113.42"
         v
  [Your Browser]
         |
         | 3. HTTP GET Request to 203.0.113.42
         |    "Please send: /lessons/html-basics.html"
         v
  [Web Server at learningsite.edu]
         |
         | 4. HTTP Response: 200 OK
         |    [html-basics.html file contents]
         v
  [Your Browser]
         |
         | 5. Browser reads HTML, finds links to:
         |    - /css/main.css
         |    - /js/main.js
         |    - /images/diagram.png
         |
         | 6. Sends separate requests for each linked resource
         v
  [Web Server responds with each file]
         |
         v
  [Browser builds and displays the page]
  1. In the diagram above, which device is acting as the client?
  2. How many separate HTTP requests does the browser make to load this page? List all of them.
  3. Suppose the server cannot find the file /lessons/html-basics.html. What HTTP status code would it send back?
  4. What is the purpose of the DNS lookup in step 1? Why can the browser not skip this step and go directly to the server?
  5. If a user visits the same page again a few minutes later, which steps might be skipped or shortened, and why?
  6. Identify the following parts of this URL: https://www.learningsite.edu/lessons/html-basics.html — scheme, host, and path.
  7. The web server in the diagram is located in a data center in another city. Does the user need to know the server's physical location to use the website? Explain why or why not.
ActivitiesURL Reading Practice

For each URL below, identify the scheme, host, path, query string (if present), and fragment (if present). Then answer the follow-up question.

Five URLs
Read each address carefully before answering
  • URL 1https://www.mgu.edu/programs/computer-science
  • URL 2http://example.org/blog/post.html#comments — What will the browser do with the #comments part of this URL?
  • URL 3https://search.example.com/results?q=web+development&page=2 — How many query parameters does this URL contain? What are their names and values?
  • URL 4https://resources.learningsite.edu/downloads/starter-kit.zip — Based on the path, what type of file is being requested? What do you expect the server to send back?
  • URL 5http://localhost:3000/index.html — What does localhost tell you about where this file is stored? What does :3000 indicate?
ActivitiesRequest-and-Response Questions

Answer each question in one or more complete sentences.

  1. A user visits a web page and sees the message "404 Not Found." What does this status code mean? What are two possible reasons this might happen?
  2. A user visits a web page and is redirected to a new URL they did not type. The browser address bar now shows a different URL than the one they typed. What status codes might have caused this redirect?
  3. A website loads quickly the first time you visit, and then loads almost instantly when you visit again a minute later. What caching behavior could explain this? Which HTTP status code is associated with a cached response that has not changed?
  4. You are building a web page. You add a link to an image using a relative path, but the image does not appear when you open the page in a browser. You open the browser's developer tools and see a status code of 404 for the image request. What does this tell you about the problem?
  5. A website uses http:// instead of https://. A user connects to this site from a coffee shop's public Wi-Fi. What risk does the user face? What risk does the website owner face?
  6. Explain in your own words why loading a web page often involves many separate HTTP requests rather than just one.

Concept Check

Decide whether each statement is true or false. If a statement is false, write a corrected version.

  1. The internet and the World Wide Web are the same thing.
  2. A browser is a type of client software.
  3. When a browser requests a web page, it sends a request to the nearest DNS server and the DNS server sends back the HTML file.
  4. A 200 status code means the request succeeded and the server is sending back the requested content.
  5. HTTPS protects data by encrypting it as it travels between the browser and the server.
  6. If you open an HTML file by double-clicking it on your desktop, your browser is making an HTTP request to a server.
  7. You can serve the same website files to users in any country without setting up a server in each country.
  8. A web server that delivers files exactly as they are stored, without generating content on the fly, is called a static web server.

Common Misconceptions

Misconception 1
"The internet is the web."
The internet is the underlying network infrastructure. The web is one system that runs on top of it. Email, file transfers, and online games also run on the internet but are not part of the web. When you build a website, you are building for the web — which runs on the internet but is not the same as it.
Misconception 2
"Changing my files changes the live website."
Your local files on your computer and the files on a web server are separate. Editing your local copy does not update the published website. To update a live site, you must transfer the changed files to the server. This is called deployment, and you will learn about it in Chapter 30.
Misconception 3
"file:// and http://localhost are the same thing."
Both let you view your HTML in a browser, but they behave differently. The file:// protocol opens files directly from your disk without going through any server. http://localhost serves files through a local web server. Some JavaScript features, security policies, and path behaviors differ between the two. Use a local server for serious development work.
Misconception 4
"A domain name and web hosting are the same purchase."
They are two separate things. A domain name is the human-readable address (yoursite.com). Hosting is the service that stores and serves your files. You register a domain name with a registrar and separately set up hosting with a hosting provider, then connect the two through DNS settings.
Misconception 5
"My website only needs HTTP; HTTPS is too complicated."
Modern browsers warn users that HTTP sites are "not secure." HTTPS is required for many browser features, preferred by search engines, and fundamental to protecting user data. Free certificates are widely available. There is no good reason to use HTTP on a published site.
ReviewReview Questions
  1. What is the difference between the internet and the World Wide Web? Give one example of an internet service that is not part of the web.
  2. Describe the client-server model in your own words. In this model, what is the role of the browser?
  3. What are the five components of a URL? Give an example URL and identify each component.
  4. What is DNS, and why is it necessary? What would web browsing look like if DNS did not exist?
  5. What is the difference between HTTP and HTTPS? Why should published websites use HTTPS?
  6. A web developer opens their HTML file by double-clicking it and notices a JavaScript feature is not working. They switch to using a local development server and the feature works correctly. Why might this happen?
  7. What is the difference between a domain name and web hosting? Can you have one without the other?
  8. When a browser loads a web page that contains three images and one CSS file, how many HTTP requests are made in total? Explain your answer.
  9. A user sees a 404 error on a page that was working yesterday. You are the developer. What are three things you would check first?
  10. What does it mean to say that the web is built on open standards? Why does this matter for web developers?
Chapter 2 Checklist
Use this to confirm your understanding before moving to Chapter 3
Concepts
  • I can distinguish the internet from the World Wide Web and name a service that uses the internet but not the web.
  • I can describe the client-server model and explain the role of the browser within it.
  • I can list the main responsibilities a browser performs when loading a page.
  • I can explain what a web server does and distinguish static from dynamic servers.
  • I can identify the five components of a URL and explain what each one does.
  • I can describe the request-response cycle and interpret common HTTP status codes.
  • I can explain the difference between HTTP and HTTPS and why HTTPS matters.
  • I can explain how DNS connects a domain name to an IP address.
  • I can distinguish between a domain name and web hosting.
Applications
  • I can explain the practical difference between file:// and a local development server.
  • I can trace the full sequence of events that occurs when a browser loads a web page.
  • I can read a URL and correctly identify its scheme, host, path, query string, and fragment.
  • I can explain why open web standards let the same code work across browsers and devices.
Preview — Chapter 3
Files, Folders, Paths, and Project Structure

Chapter 2 explained how files travel across the internet from server to client. But before files can travel, they must exist — organized and named correctly on both your development machine and the server. Chapter 3 digs into project organization: how to structure a web project folder, what file extensions mean, how relative and absolute paths work, how to link your HTML, CSS, JavaScript, and image files together correctly, and how to name files so they behave properly on servers. Broken file paths are one of the most common beginner problems in web development. Chapter 3 gives you the foundations to avoid them.

MGU Library Connection
  • Web Development: HTML, CSS, and JavaScript — Appendix A: Web Project Setup Reference
  • Web Development: HTML, CSS, and JavaScript — Appendix J: Developer Tools and Debugging Reference
  • Companion resource: Browser Developer Tools Guide
  • Companion resource: Link and Path Guide
  • Next section: Chapter 3 — Files, Folders, Paths, and Project Structure
  • MGU Computer Science Foundations — background reading on computation, networks, and systems