MGU Computer Science Series — Computer Science Foundations
Part V: Networks, Web, and Security
Clients · Servers · URLs · HTTP · HTML · CSS · JavaScript · Web Apps
Chapter 20 of 28
MGU Computer Science Series  ·  Computer Science Foundations  ·  Library Textbook Edition

Chapter 20:
The World Wide
Web

Clients and servers, URLs, HTTP and HTTPS, browsers, HTML as structure, CSS as presentation, JavaScript as behavior, web applications, search engines, accessibility, and hosting

■ Part V: Networks, Web, and Security ■

■ 10 Sections  •  Chapter 20 of 28 ■

Builds on Chapter 19: Networks and the Internet  ·  Prepares students for Chapter 21: Cybersecurity Foundations

Purpose and Overview

Every day, billions of people open a browser, type an address, and within seconds see a page assembled from files stored on a computer thousands of miles away. Understanding what actually happens in those seconds — the addresses, the requests, the responses, the languages, the protocols — is one of the most practical skills a computer scientist can have. The web is not magic. It is a carefully designed system built from a small number of powerful ideas.

Chapter 20 explains the World Wide Web as a major service that runs on top of the internet. Students will learn how browsers and servers communicate, how web addresses work, how documents travel across the network, and how HTML, CSS, and JavaScript each play a distinct role in what appears on screen. The chapter draws a clear line between the internet — the global network of computers — and the web, one service that uses that network.

By the end of this chapter, students will understand what happens when they type a URL, click a link, or submit a form. This chapter builds directly on Chapter 19 (Networks and the Internet) and prepares students for Chapter 21 (Cybersecurity Foundations) and later courses in web development, networking, and security.

Connection to Chapter 19

Chapter 19 introduced the internet as a network of networks: packets, routers, IP addresses, DNS, and protocols. This chapter narrows its focus to the web layer that sits on top of that infrastructure. Everything from Chapter 19 — how packets travel, how DNS resolves names, how protocols define communication — applies directly here. The web is a service that uses all of those mechanisms.

10Sections
12Objectives
40+Key Terms
3Core Web Languages

Learning Objectives

  1. 1Distinguish between the internet and the World Wide Web and give examples of services that use the internet but are not the web.
  2. 2Explain the client-server model as it applies to web browsers and web servers.
  3. 3Identify and describe each component of a URL: scheme, host, path, query string, and fragment.
  4. 4Describe what an HTTP request and HTTP response contain, and interpret common HTTP status codes.
  5. 5Explain how HTTPS uses TLS to encrypt communication and authenticate servers.
  6. 6Describe the sequence of steps a browser performs from URL entry to page display.
  7. 7Explain the role of HTML as structure, CSS as presentation, and JavaScript as behavior in a web page.
  8. 8Read simple HTML elements and attributes and explain what they communicate.
  9. 9Read a basic CSS rule and identify its selector, properties, and values.
  10. 10Describe how JavaScript interacts with the DOM and responds to user events.
  11. 11Explain what a web application is and how it differs from a website.
  12. 12Describe web accessibility principles and explain why they matter.

Sections at a Glance

Sections 20.1 – 20.3
The Web's Foundation: What It Is and How It's Addressed
Internet vs. Web · Clients and Servers · URLs

The Internet and the Web Are Not the Same

Most people use the words internet and web interchangeably. In everyday conversation, the difference rarely matters. In computer science, it matters a great deal.

The internet is a global infrastructure: a worldwide network of computers connected by physical cables, fiber optics, wireless links, and satellite connections. The internet is the hardware and software layer that allows computers anywhere on Earth to send packets of data to each other. It does not belong to any one company or government. It is a shared system built on open standards and protocols.

The World Wide Web — almost always called simply the web — is a service that runs on top of the internet. The web is a collection of documents, images, videos, and interactive applications that are linked together and accessed through a browser. The web uses the internet to deliver its content, but it is not the only service that uses the internet.

The Key Distinction

Internet = the global network infrastructure (the "roads")

Web = a service that uses that infrastructure (one kind of "traffic")

Other services also use the internet but are not the web. Email follows a different set of protocols (SMTP, IMAP, POP3). Video calls transmit live audio and video streams without loading web pages. Online gaming sends game state between players and servers in real time. File transfer applications use protocols such as FTP or SFTP. Streaming audio and video use their own delivery systems. All of these services share the internet's underlying infrastructure. None of them are the internet, and none of them are the web — though some services are also available through a web interface.

The web was invented by Tim Berners-Lee in 1989 while he was working at CERN, the physics research organization in Switzerland. His original goal was modest: help scientists share documents and link related information across a network. He proposed three foundational ideas that remain at the heart of the web today.

Founding IdeaWhat It IsWhat It Does
HTMLHyperText Markup LanguageA language for marking up documents with structure and meaning
URLUniform Resource LocatorA system for giving every document a unique, human-readable address
HTTPHyperText Transfer ProtocolA protocol for requesting and delivering documents across a network

From those three ideas, the web grew into the largest information system ever created. The first website went online in 1991. Today, billions of websites exist, and the web underlies e-commerce, news, social media, banking, education, government services, entertainment, and much of modern scientific research. Understanding the web means understanding these three original ideas — plus the later additions that have made it interactive, secure, accessible, and programmable.

Practice 20.1Concept Check
  1. In your own words, explain the difference between the internet and the World Wide Web.
  2. Name three services that use the internet but are not the World Wide Web. For each, briefly explain why it is not part of the web.
  3. Tim Berners-Lee proposed three founding ideas for the web. Name each one and describe what problem it solved.

Clients and Servers

The web is built on a relationship between two types of machines: clients and servers.

A server is a computer — or a program running on a computer — that stores resources and waits for requests. When a request arrives, the server delivers a response. Web servers store HTML files, images, videos, stylesheets, scripts, and data. They run continuously, listening for incoming connections. A client is a computer — or a program running on a computer — that makes requests to servers. On the web, a browser is the client. When you type a URL into a browser, the browser sends a request to a server and waits for the response. This pattern is called the client-server model.

Diagram: The Client-Server Model
Client (browser)                    Server (web server)
      |                                      |
      |  ---- sends a request ------------>  |
      |                                      |
      |  <--- sends a response -----------   |
      |                                      |
      |  (browser displays the response)     |

The client and server do not need to be in the same building, city, or country. When you load a page from a website hosted in a data center on the other side of the world, your browser is the client and a computer in that data center is the server. The request travels across the internet as packets, reaching the server in milliseconds.

One server, many clients. A popular web server may handle millions of requests per day from clients all over the world. Each client makes a separate request; the server processes them and sends back responses. The clients do not communicate with each other — they only communicate with the server. One client, many servers. A single web page often requires resources from multiple servers. The HTML might come from one server, the images from another, the fonts from a third, and analytics scripts from a fourth. The browser makes separate requests for each resource, then assembles the final page on screen.

Servers Are Not Magical

A web server is just a computer running server software (such as Apache, Nginx, or Microsoft IIS) that listens on a network port and responds to HTTP requests. A powerful laptop running server software can act as a web server. Large companies use thousands of servers working together in data centers to handle traffic at scale.

Practice 20.2Concept Check
  1. Define the terms client and server as they are used in the web context.
  2. When you load a web page that includes three images from a CDN, a stylesheet from a hosting provider, and HTML from the main server, how many separate client-server exchanges occur at minimum?
  3. Explain why the client-server model also describes email and online gaming, even though those services are not the web.

URLs

Every resource on the web has an address. That address is called a URL, which stands for Uniform Resource Locator. A URL is a standardized way of identifying exactly where a resource can be found on the web. Consider this example:

Anatomy of a URL
https://www.example.edu/courses/intro-cs/chapter20.html?section=3#exercises
|                |                 |                     |          |
scheme           host (domain)     path                  query      fragment
ComponentExampleWhat It Identifies
SchemehttpsWhich protocol to use. https = secure HTTP; http = standard HTTP; mailto: = email; ftp: = file transfer.
Host (domain)www.example.eduWhich server to contact. The browser uses DNS to translate this into an IP address.
Path/courses/intro-cs/chapter20.htmlWhich specific resource on the server is being requested. Resembles a file system path.
Query string?section=3Additional parameters passed to the server or page. Multiple parameters separated by &.
Fragment#exercisesA location within the page. The browser uses this after the page loads — it is never sent to the server.

URL Design

Well-designed URLs are readable, predictable, and stable. Compare these two URLs for the same page:

URL Design — Readable vs. Opaque
// Readable — communicates meaning
https://example.edu/courses/intro-cs/chapter20

// Opaque — reveals nothing to a reader
https://example.edu/page?id=84729&ref=3&v=2

The first URL tells a reader something meaningful: it is a page about introductory computer science, chapter 20. The second reveals nothing. Good URL design makes websites easier to use, easier to share, and easier for search engines to index. Modern web applications often construct URLs dynamically — there may be no actual file named chapter20.html on the server. The server generates the page content on the fly. But the URL structure still resembles a file path for readability.

Practice 20.3URL Analysis

Read this URL carefully and answer each question.

URL for Analysis
https://library.mgu.edu/search?query=algorithms&type=book&page=2#results
  1. Identify the scheme in this URL.
  2. Identify the host (domain name).
  3. Identify the path.
  4. List each query string parameter and its value.
  5. Identify the fragment identifier. What does the browser do with this value?
  6. Does the server receive the fragment identifier as part of the request? Explain why or why not.
Sections 20.4 – 20.5
The Protocol and the Browser
HTTP · HTTPS · Status Codes · How Browsers Work

HTTP and HTTPS

When a browser has determined a server's IP address (via DNS) and established a connection, it sends a request using a protocol called HTTP — HyperText Transfer Protocol. HTTP defines exactly how browsers ask for resources and how servers respond.

HTTP Requests

An HTTP request has several parts. The method describes what the client wants to do. The two most common are GET (retrieve a resource — used when you type a URL or click a link) and POST (send data to the server — used when you submit a form). The request also carries headers: key-value pairs providing additional information such as the host being contacted, what content types the client accepts, and any cookies to send back.

Example 20.4.1
A simplified HTTP exchange
  • Request GET /chapter20.html HTTP/1.1 Host: example.edu User-Agent: Mozilla/5.0 Accept: text/html
  • Response HTTP/1.1 200 OK Content-Type: text/html Content-Length: 8432 <!DOCTYPE html> <html> ... (the HTML document follows)
  • MeaningThe browser requests the file chapter20.html using the GET method. The server responds with status 200 (success), declares the content type as HTML, and sends the document in the response body.

HTTP Status Codes

Every HTTP response begins with a three-digit status code indicating the result. Status codes are grouped by their first digit.

RangeCategoryCommon Examples
2xxSuccess200 OK — request succeeded and resource is in the response body.
201 Created — a new resource was created (used with POST).
3xxRedirection301 Moved Permanently — the URL has changed; use the new URL in future.
302 Found — temporary redirect.
4xxClient error400 Bad Request — the request was malformed.
403 Forbidden — access denied.
404 Not Found — the resource does not exist on this server.
5xxServer error500 Internal Server Error — the server encountered an unexpected problem.
503 Service Unavailable — the server is temporarily down or overloaded.
404 Does Not Mean the Whole Site Is Down

A 404 error means the specific requested resource was not found on the server. The server is running and responding — it simply could not find the file at the requested path. Other pages on the same site may work perfectly.

HTTPS: Encrypted HTTP

Standard HTTP sends all data in plain text. Any computer along the route between the browser and the server could, in principle, read the request and response. This creates serious problems for login forms, payment information, private messages, and any other sensitive data.

HTTPS (HyperText Transfer Protocol Secure) solves this by encrypting the communication using a system called TLS (Transport Layer Security). Before the HTTP exchange begins, the browser and server perform a TLS handshake — a negotiation in which they establish a shared encryption key. After the handshake, all data is encrypted. An observer watching the network traffic sees only scrambled data.

HTTPS also provides authentication: the server presents a certificate issued by a trusted certificate authority, proving it really is the site it claims to be. This prevents an attacker from intercepting the connection and impersonating the website. Browsers indicate HTTPS connections with a padlock icon in the address bar. Modern browsers mark non-HTTPS sites as "Not Secure."

Common Misconception — HTTPS and Trust

HTTPS means the connection between your browser and the server is encrypted and that the server's identity has been verified. It does not mean the website's content is honest or safe. A phishing site can have a valid HTTPS certificate. Always evaluate the site itself, not only the padlock.

Practice 20.4HTTP and HTTPS
  1. What is the difference between the HTTP GET and POST methods? Give a real-world example of when each would be used.
  2. A server returns status code 301 with a header Location: https://example.edu/new-page. What should the browser do next?
  3. You visit a website that asks for your password. The address bar shows http:// without a padlock. Explain why this is a serious security concern.
  4. Name two things HTTPS provides beyond what plain HTTP provides. For each, explain why it matters to a user submitting personal information.

Browsers

A browser is a software application that requests web resources, interprets them, and displays them to the user. Browsers are clients in the client-server model. They translate the raw text of HTML, CSS, and JavaScript into the visual, interactive pages that users see on screen.

What a Browser Does

Browser Rendering Sequence
 1  Parse the URL
    (scheme, host, path, query, fragment)
        |
 2  Resolve the domain via DNS
    (domain → IP address)
        |
 3  Establish HTTPS connection
    (TLS handshake with server)
        |
 4  Send HTTP GET request
        |
 5  Receive HTTP response
    (status code, headers, HTML body)
        |
 6  Parse the HTML → build the DOM
    (Document Object Model)
        |
 7  Fetch additional resources
    (stylesheets, scripts, images, fonts)
        |
 8  Apply CSS
    (compute how every element looks)
        |
 9  Execute JavaScript
    (modify DOM, respond to events, fetch data)
        |
10  Render the page on screen

This entire sequence often completes in under a second for simple pages. Complex pages with many resources may take several seconds. A browser is, in part, an interpreter — it reads and executes code (HTML, CSS, JavaScript) and produces a visual result. Browsers handle poorly written code gracefully: if HTML contains a mistake, the browser tries to display something reasonable rather than showing an error message. This is called fault tolerance and was a deliberate design choice in early web standards.

Browsers also sit between users and the web as security gatekeepers. They verify HTTPS certificates, block known malicious sites, enforce rules preventing one website from reading another website's data, manage cookies, and allow users to control permissions for camera, microphone, location, and notifications.

Practice 20.5Browser Behavior
  1. After the browser receives the initial HTML response, it discovers references to three external images, one CSS file, and one JavaScript file. How many additional HTTP requests does it need to send?
  2. At which step in the browser's rendering sequence does DNS play a role?
  3. Explain what "fault tolerance" means in the context of HTML parsing. Why was this choice made when designing early browsers?
Sections 20.6 – 20.8
The Three Languages of the Web
HTML as Structure · CSS as Presentation · JavaScript as Behavior

HTML as Structure

HTML (HyperText Markup Language) is the language used to describe the structure and content of a web page. It is not a programming language — it does not perform calculations or make decisions. HTML marks up content, labeling each piece as a particular kind of thing: a heading, a paragraph, a list, a link, an image, a table, a form.

Tags, Elements, and Attributes

HTML uses tags to mark up content — a keyword enclosed in angle brackets. Most tags come in pairs: an opening tag and a closing tag, with content between them. The opening tag, closing tag, and their content together form an element. Attributes are name-value pairs inside the opening tag that provide additional information about the element.

HTML Elements and Attributes
<!-- A paragraph element -->
<p>This is a paragraph.</p>

<!-- A hyperlink with href and target attributes -->
<a href="chapter21.html" target="_blank">Next Chapter</a>

<!-- An image with src and alt attributes -->
<img src="network-diagram.png" alt="A diagram showing client-server communication" width="600">
ElementPurposeExample
<h1> – <h6>Headings, from most to least important<h1>Chapter 20</h1>
<p>Paragraph of text<p>The web is built on HTTP.</p>
<a>Hyperlink (anchor)<a href="ch21.html">Next</a>
<img>Embeds an image<img src="net.png" alt="Network">
<ul> / <ol>Unordered / ordered listContains <li> items
<table>Data tableContains <tr>, <th>, <td>
<form>User input formContains <input>, <button>
<header>, <nav>, <main>, <footer>Semantic landmark regionsCommunicate page structure to browsers and screen readers

A Complete HTML Document

Complete HTML Document Structure
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chapter 20: The World Wide Web</title>
    <link rel="stylesheet" href="styles.css">
  </head>
  <body>
    <header>
      <h1>Chapter 20: The World Wide Web</h1>
    </header>
    <main>
      <p>The web is a system of linked documents and applications.</p>
      <h2>20.1 The Internet and the Web Are Not the Same</h2>
      <p>Most people use these terms interchangeably...</p>
    </main>
    <footer>
      <p>MGU Computer Science Series</p>
    </footer>
  </body>
</html>
Semantic HTML

HTML describes what content is, not how it looks. A heading element communicates "this is the most important heading on the page" — it does not specify font, color, or size. That is CSS's job. When HTML is written to communicate meaning (not just appearance), it is called semantic HTML. Using <h1> for the main heading, <nav> for navigation, and <footer> for the footer gives browsers, search engines, and assistive technologies meaningful information about the page's structure.

HTML Is Not a Programming Language

HTML is a markup language. It describes content and structure. It does not perform calculations, make decisions, or repeat operations. Python, JavaScript, and Java are programming languages. HTML is not. Confusing these categories is one of the most common misconceptions in computer science education.

Practice 20.6Code Review — HTML

Read each HTML fragment and answer the questions without running code.

Fragment A
<nav>
  <a href="index.html">Home</a>
  <a href="chapter19.html">Chapter 19</a>
  <a href="chapter20.html">Chapter 20</a>
</nav>
  1. What does the <nav> element communicate to a browser or screen reader?
  2. What would the href attribute need to contain to link to an external website?
  3. Rewrite the second link so that it opens in a new browser tab. What attribute value would you add?
Fragment B
<img src="network-diagram.png">
  1. What is missing from this element? What problem does the absence cause, and for whom?
  2. Rewrite this element with a complete and appropriate alt attribute.

CSS as Presentation

CSS (Cascading Style Sheets) is the language used to describe how HTML elements should look: their colors, fonts, sizes, spacing, positions, borders, backgrounds, animations, and responses to different screen sizes. HTML gives a page structure and meaning. CSS gives it appearance and layout.

Rules, Selectors, and Declarations

CSS consists of rules. Each rule has two parts: a selector — which elements the rule applies to — and a declaration block — a set of property-value pairs in curly braces. Each line inside the block is a declaration: a property name, a colon, a value, and a semicolon.

CSS Rules — Selectors and Declarations
/* Element selector — all h1 headings */
h1 {
  color: #2c4a6e;
  font-size: 2rem;
  font-family: Georgia, serif;
  margin-bottom: 1rem;
}

/* Class selector — elements with class="note" */
.note {
  background-color: #fffbe6;
  border-left: 4px solid #f0c040;
  padding: 1rem;
}

/* ID selector — the element with id="main-heading" */
#main-heading {
  text-align: center;
}

/* Descendant selector — links inside nav elements */
nav a {
  text-decoration: none;
  color: #2c4a6e;
}
PropertyControlsExample Value
colorText color#333333, blue
background-colorBackground fill#f5f5f5, white
font-familyTypefaceArial, sans-serif
font-sizeText size16px, 1.2rem
marginSpace outside element1rem, 0 auto
paddingSpace inside element0.5rem 1rem
displayLayout behaviorblock, flex, grid
borderOutline around element1px solid #ccc

The Cascade

The "cascading" in Cascading Style Sheets refers to how CSS resolves conflicts when multiple rules apply to the same element. CSS uses a system of specificity: more specific selectors override less specific ones. ID selectors (#id) are more specific than class selectors (.class), which are more specific than element selectors (p, h1). Rules defined later in a stylesheet override earlier rules of equal specificity.

Responsive Design

Web pages are viewed on devices with vastly different screen sizes. Responsive design is the practice of writing CSS that adapts the layout to fit the available screen space. The primary tool is the media query, which applies styles only when certain conditions are met.

Responsive Design with Media Queries
/* Default: three-column layout on large screens */
.container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

/* On screens narrower than 600px: single column */
@media (max-width: 600px) {
  .container {
    grid-template-columns: 1fr;
  }
}
Practice 20.7Code Review — CSS
CSS Rule for Analysis
.warning {
  background-color: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 1rem;
  font-weight: bold;
}
  1. What kind of selector is .warning? What does the dot indicate?
  2. How would you apply this style to a paragraph element in HTML?
  3. Name two visual properties this rule sets. For each, describe what it controls.
  4. A developer wants this same style to apply only to the element with id="alert-box". Rewrite the selector.

JavaScript as Behavior

HTML provides structure. CSS provides appearance. JavaScript provides behavior.

JavaScript is a full programming language that runs inside the browser. It can respond to user actions, change the content and styling of a page after it has loaded, communicate with servers in the background, validate form input, animate elements, and much more. JavaScript is the only programming language that all major browsers support natively.

JavaScript and the DOM

JavaScript interacts with a page through the DOM (Document Object Model) — the browser's internal representation of the HTML document as a tree of objects. JavaScript can read and modify the DOM to change what the user sees.

JavaScript DOM Manipulation
// Select an element and change its text
document.getElementById("status-message").textContent = "Loading complete.";

// Select all elements with a class and hide them
const notes = document.querySelectorAll(".note");
notes.forEach(function(note) {
  note.style.display = "none";
});

// Respond to a button click
document.getElementById("submit-button").addEventListener("click", function() {
  alert("Form submitted!");
});

Events

JavaScript programs on the web are largely event-driven. Rather than running once from top to bottom, JavaScript code registers functions to run when specific events occur: a user clicks a button (click), presses a key (keydown), submits a form (submit), or data arrives from a server. This event-driven model is different from the sequential programs introduced in earlier chapters.

Communicating with Servers (Fetch)

One of JavaScript's most powerful capabilities is communicating with servers in the background after a page has already loaded, without reloading the page. This technique — called fetch or AJAX — allows web applications to update specific parts of a page without a full page reload.

JavaScript Fetch — Background Server Communication
// Request data from a server in the background
fetch("https://api.example.edu/courses")
  .then(function(response) {
    return response.json();
  })
  .then(function(data) {
    console.log(data);
    // Update the page with the received data
  });
The Three Web Languages Together

HTML → The content and structure ("what is here")

CSS → The appearance and layout ("what it looks like")

JavaScript → The behavior and interactivity ("what it does")

Each language has a distinct responsibility. Mixing them carelessly creates pages that are harder to maintain and harder for assistive technologies to understand.

Practice 20.8Code Review — JavaScript
JavaScript Snippet for Analysis
let count = 0;

document.getElementById("increment").addEventListener("click", function() {
  count = count + 1;
  document.getElementById("display").textContent = "Count: " + count;
});
  1. What event does this code respond to?
  2. What happens to the count variable each time the event occurs?
  3. What element on the page gets its text updated?
  4. If the button is clicked five times, what text will the #display element contain?
  5. How is this event-driven program different from the sequential programs studied in Chapter 8?
Sections 20.9 – 20.10
The Web Ecosystem
Web Applications · Search Engines · Accessibility · Hosting

Web Apps

The web began as a system for sharing documents. Today it is also a platform for full-featured software applications. A website primarily delivers content — articles, product pages, portfolios, documentation — and the user mostly reads and navigates. A web application (or web app) allows the user to do something: edit a document, compose an email, process a payment, play a game, collaborate with others in real time.

Examples of web apps include Google Docs, Gmail, GitHub, Figma, Trello, online banking portals, e-commerce checkout systems, video streaming controls, and learning management systems. These use JavaScript far more heavily than simple websites. Much of the logic that would traditionally run on a server now runs in the browser.

Single-Page Applications

Single-Page Applications (SPAs) load a single HTML file once and then use JavaScript to update the page dynamically as the user interacts with it. The URL may change, and content appears and disappears, but the browser never does a full page reload. Gmail is a well-known example.

Frameworks such as React, Vue, and Angular are JavaScript libraries that help developers build complex web applications by providing organized patterns for managing page structure, state, and updates. These frameworks are not part of the web standard but have become standard tools in professional web development.

APIs and the Front-End / Back-End Division

Web apps communicate with servers through APIs (Application Programming Interfaces) — defined sets of URLs that return data (usually in JSON format) rather than HTML pages. The web app's JavaScript code requests data from the API and uses it to update the page.

DomainWhat It CoversExample Technologies
Front-endWork done in the browser: HTML, CSS, JavaScript, user interface, accessibility, performanceHTML, CSS, JavaScript, React, Vue
Back-endWork done on the server: request handling, databases, data processing, authenticationPython, Node.js, Ruby, Java, SQL
Full-stackWork across both front-end and back-endAny combination of the above
Practice 20.9Web Apps
  1. What is the key distinction between a website and a web application? Give one specific example of each and explain what makes the web app more than a document.
  2. A news aggregator shows articles from 15 different news sources, fetched live without storing them on the aggregator's own servers. Explain how web APIs make this architecture possible.
  3. When you add an item to a shopping cart and the cart count updates without the page reloading, which web technology is responsible? Describe the general mechanism.

Search Engines, Accessibility, and Hosting

Search Engines

A search engine is a system that indexes the web and allows users to find pages by entering search terms. Search engines operate automated programs called crawlers (or spiders) that follow links from page to page across the web, downloading and indexing each page's content. Starting from a set of known URLs, the crawler discovers new pages by following every link it finds.

The index is a massive database mapping words and phrases to the pages where they appear. When a user enters a search query, the search engine ranks relevant pages by measures of relevance and quality. Search Engine Optimization (SEO) is the practice of designing pages to rank highly in search results. Good SEO begins with well-written, useful content and semantic HTML — descriptive titles, meaningful headings, clear URL structures, and fast loading times.

Search Engines Cannot Index Everything

Search engines crawl and index publicly accessible pages. Pages requiring login, pages instructing crawlers not to visit them (via a robots.txt file), content behind paywalls, and database-driven content only accessible through search forms are generally not indexed. This unindexed portion of the web is sometimes called the deep web.

Web Accessibility

Web accessibility means designing and building web pages so that people with disabilities can use them effectively. Disabilities that affect web use include visual impairments (blindness, low vision, color blindness), motor impairments (difficulty using a mouse or keyboard), auditory impairments, and cognitive differences.

Screen readers are software programs used by people who are blind or have low vision. A screen reader reads page content aloud and allows the user to navigate by headings, links, and other structural elements. For a screen reader to work well, HTML must be semantic and complete: headings in logical order, images with descriptive alt text, form inputs with clear labels, and links that describe their destination.

Keyboard navigation is important for users who cannot use a mouse. Interactive elements must be reachable and usable with a keyboard alone.

WCAG and the POUR Principles

The Web Content Accessibility Guidelines (WCAG) are an international standard for web accessibility. They are organized around four principles:

Perceivable — Information must be presentable in ways all users can perceive.

Operable — Interface components must be operable by all users.

Understandable — Information and interface must be understandable.

Robust — Content must work with current and future assistive technologies.

Accessibility is not an optional feature. It is both an ethical responsibility and, in many contexts, a legal requirement.

Web Hosting

Web hosting is the service of providing the infrastructure — servers, power, internet connections, storage — that keeps websites running. Options range widely.

Hosting TypeDescriptionSuitable For
Shared hostingMany websites share one physical server. Inexpensive, limited performance and control.Small, low-traffic websites
VPS hostingIsolated environment on shared hardware. More control and better performance.Medium-traffic sites
Dedicated serverA physical server for one customer. Maximum control; highest cost.High-demand applications
Cloud hostingDistributed across many servers. Flexible and scalable.Large websites and web apps
CDNDelivers content from servers geographically close to each user, reducing latency.Static assets, global traffic
Domain Registration vs. Hosting

Domain registration (obtaining a name like example.edu) is separate from hosting. A domain registrar stores DNS records mapping the name to the server's IP address. Registration typically involves an annual fee. You can register a domain with one provider and host with a completely different one.

Practice 20.10Search, Accessibility, and Hosting
  1. Explain how a search engine crawler discovers new web pages. What prevents it from finding every page on the web?
  2. A web page has the following heading structure: <h1>, then <h3>, then <h2>. What problem does this create, and for whom?
  3. A small nonprofit expects fewer than 500 visitors per month and has a limited budget. Which hosting type would you recommend? Explain your reasoning.
  4. What is a CDN and why would a website serving a global audience benefit from one?

Common Misconceptions

Misconception 1 — "The internet and the web are the same thing."
The terms internet and web mean the same thing and can be used interchangeably.

The internet is the global network infrastructure. The web is one service that uses it. Email, video calls, and gaming also use the internet but are not the web.

Misconception 2 — "HTML is a programming language."
HTML is a programming language because it makes web pages.

HTML is a markup language. It describes content and structure. It does not perform calculations, make decisions, or repeat operations. JavaScript is the programming language of the web.

Misconception 3 — "HTTPS means the website is safe and trustworthy."
The padlock icon means I can trust everything on this site.

HTTPS means the connection is encrypted and the server's identity is verified. It says nothing about the honesty or safety of the site's content. Phishing sites can and do use HTTPS.

Misconception 4 — "A 404 error means the whole website is down."
I got a 404, so the website must be broken or offline.

A 404 means the specific requested resource was not found. The server is running and responding. Other pages on the same site are likely working fine.

Misconception 5 — "CSS only controls colors and fonts."
CSS is just for making things look pretty — colors, fonts, maybe some borders.

CSS controls the entire visual presentation: position, size, spacing, layout, responsiveness to screen size, animations, visibility, and print formatting. It is a sophisticated language with hundreds of properties.

Misconception 6 — "The URL fragment is sent to the server."
The #exercises part of a URL is sent to the server so it knows which section to load.

The fragment identifier is never sent to the server. The browser uses it locally after the page loads to scroll to a specific element. The server receives only the scheme, host, path, and query string.

Chapter Summary

Key Terms

URL
Uniform Resource Locator. A standardized address for a web resource: scheme, host, path, optional query, and optional fragment.
scheme
The first part of a URL specifying which protocol to use (e.g., https, http).
domain name
The human-readable name of a server, such as example.edu, translated to an IP address by DNS.
path
The portion of a URL identifying a specific resource on a server, resembling a file system path.
query string
The portion of a URL after ?, containing key-value parameters passed to the server or page.
fragment identifier
The portion of a URL after #, identifying a location within the page. Never sent to the server.
HTTP
HyperText Transfer Protocol. Defines how browsers request resources and how servers respond.
HTTPS
HTTP Secure. Encrypts HTTP communication using TLS and authenticates servers via certificates.
TLS
Transport Layer Security. The encryption protocol used by HTTPS to protect communication.
status code
A three-digit number in an HTTP response indicating the result: 2xx success, 3xx redirect, 4xx client error, 5xx server error.
client
A program (typically a browser) that sends requests to a server and processes responses.
server
A program or computer that stores resources, listens for requests, and sends responses.
client-server model
The architectural pattern in which clients request resources from servers that respond to those requests.
browser
A software application that requests, interprets, and displays web resources.
DOM
Document Object Model. The browser's internal tree representation of an HTML document, which JavaScript can read and modify.
HTML
HyperText Markup Language. Describes the structure and content of web pages using elements and attributes. A markup language, not a programming language.
element
An HTML construct consisting of an opening tag, optional content, and a closing tag.
attribute
A name-value pair inside an HTML opening tag providing additional information about the element.
semantic HTML
HTML that uses elements to communicate the meaning of content, not just its appearance.
CSS
Cascading Style Sheets. Describes the appearance and layout of HTML elements using rules, selectors, and declarations.
selector
The part of a CSS rule specifying which HTML elements the rule applies to.
declaration
A property-value pair within a CSS rule specifying one aspect of an element's appearance.
cascade
The process by which CSS resolves conflicts between rules using specificity and order.
responsive design
CSS that adapts a page's layout to fit different screen sizes, typically using media queries.
media query
A CSS feature applying styles only when certain conditions are met, such as a screen width threshold.
JavaScript
A full programming language that runs in the browser, enabling interactive and dynamic web pages.
event
A user action or browser occurrence (click, keypress, page load) to which JavaScript can respond.
fetch / AJAX
A technique for JavaScript to request data from a server in the background without reloading the page.
web application
A web-based software application allowing users to perform tasks, as distinct from a content-focused website.
SPA
Single-Page Application. A web app that loads once and updates dynamically using JavaScript without full page reloads.
API
Application Programming Interface. A defined set of URLs that return data (usually JSON) rather than HTML pages.
front-end
Development work in the browser: HTML, CSS, JavaScript, user interface, and accessibility.
back-end
Development work on the server: request handling, databases, data processing, and authentication.
search engine
A system that crawls, indexes, and ranks web pages to help users find information.
crawler
An automated program used by search engines to follow links and download page content for indexing.
web accessibility
Designing web pages so users with disabilities can use them effectively.
WCAG
Web Content Accessibility Guidelines. An international standard organized around the POUR principles.
screen reader
Software that reads web page content aloud for users who are blind or have low vision.
CDN
Content Delivery Network. Delivers content from servers geographically close to each user, reducing latency.
web hosting
The service providing server infrastructure that keeps websites online.

Diagram Review

Diagram 1: A Web Request from Start to Finish
 1  User types URL in browser
         |
 2  Browser parses URL
    (scheme: https | host: example.edu | path: /chapter20.html)
         |
 3  Browser contacts DNS resolver
    "What is the IP address of example.edu?"
         |
 4  DNS resolver returns IP address
    "example.edu → 203.0.113.47"
         |
 5  Browser establishes HTTPS connection to 203.0.113.47
    (TLS handshake: browser and server agree on encryption key)
         |
 6  Browser sends HTTP GET request
    GET /chapter20.html HTTP/1.1
    Host: example.edu
         |
 7  Server processes request, finds file
         |
 8  Server sends HTTP 200 OK response
    Content-Type: text/html
    [HTML document in body]
         |
 9  Browser parses HTML, discovers linked resources
    (CSS file, images, JavaScript)
         |
10  Browser sends additional requests for each resource
         |
11  Browser applies CSS, executes JavaScript
         |
12  Page is rendered and displayed to user

Questions: (1) At which step is DNS involved? (2) At which step does encryption begin? (3) Why does the browser send additional requests after step 8? (4) What status code would appear in step 8 if the file did not exist?

Diagram 2: The Three Web Languages
+-------------------------+---------------------------+---------------------------+
|         HTML            |           CSS             |        JavaScript         |
+-------------------------+---------------------------+---------------------------+
| Describes WHAT is here  | Describes HOW it looks    | Describes WHAT it does    |
| Structure and content   | Appearance and layout     | Behavior and interaction  |
|                         |                           |                           |
| Headings, paragraphs,   | Colors, fonts, spacing,   | Responds to clicks,       |
| links, images, forms,   | sizes, positions,         | validates forms,          |
| tables, lists           | animations, breakpoints   | fetches data from server  |
|                         |                           |                           |
| <h1>Chapter 20</h1>   | h1 { color: #2c4a6e; }   | btn.addEventListener(     |
| <p>The web is...</p>   | p { line-height: 1.6; }  |   "click", handleClick)   |
+-------------------------+---------------------------+---------------------------+
          |                          |                           |
          +-------------- Combined in a browser ---------------+
                                     |
                          Rendered web page on screen

Concept Check

  1. What is the difference between the internet and the World Wide Web? Give one example of a service that uses the internet but is not the web.
  2. In the client-server model, what role does a browser play? What role does a web server play?
  3. What does an HTTP status code communicate? Give one example of a 2xx code and one 4xx code, and explain what each means.
  4. Why is HTTPS important for pages that ask users to log in or enter payment information?
  5. What is the purpose of the alt attribute on an <img> element? Who benefits from it being present and descriptive?
  6. Explain the difference between HTML, CSS, and JavaScript in one sentence each.
  7. What is the DOM, and why does JavaScript need it?
  8. What is the difference between a website and a web application? Give one example of each.
  9. What does a search engine crawler do? Why can search engines not index every page on the web?
  10. What are the four POUR principles of web accessibility? Briefly describe each.

Practice Questions

Part AURL Analysis

For each URL, identify the scheme, host, path, query parameters (if any), and fragment (if any).

  1. https://docs.mgu.edu/cs/chapter20
  2. http://example.com/shop?item=book&qty=2
  3. https://news.example.org/article/42#comments
  4. ftp://files.example.net/report.pdf
Part BHTTP Status Codes

Match each situation to the most appropriate HTTP status code.

  1. A user requests a page that exists and the server successfully returns it.
  2. A user tries to access a page that no longer exists on the server.
  3. A page has moved to a new permanent URL.
  4. A user tries to view a private document they are not allowed to access.
  5. The server crashes while processing a request.
Part CHTML, CSS, and JavaScript Classification

For each task, identify whether it belongs to HTML, CSS, or JavaScript.

  1. Adding a heading to a page
  2. Making text turn red on hover
  3. Validating a form before submission
  4. Defining a navigation bar's links
  5. Changing the font size for mobile screens
  6. Fetching data from an API and updating the page
  7. Marking an image with alt text
  8. Creating a three-column layout
Part DDesign and Application
  1. You are building a web page for a school library. It should include: the library's name as a top-level heading, a short description paragraph, a list of three services, and a link to a contact page. Write the complete HTML structure using correct semantic elements. Do not worry about styling.
  2. A company redesigns its website and moves pages to new URLs. The old URL http://example.com/about should now be at https://example.com/about-us. What HTTP status code should the old URL return? Why does this matter for users with bookmarks and for search engines?
  3. A web page loads slowly for users in countries far from the server. What technology would you recommend? Explain how it works and why it helps.
  4. A web app shows a list of books. When the user clicks on a title, a detail panel appears with information fetched from a server — without the page reloading. Describe what role HTML, CSS, and JavaScript each play in this feature.
  5. List three specific accessibility improvements a developer should make to this HTML: a page with no headings, images without alt text, and links that all say "click here."

Debugging and Error Analysis

Each item contains a mistake or misconception. Identify it and explain the correct behavior.

Item 1 — HTML link attribute
<a href="chapter21.html" target="new_tab">Next Chapter</a>

The developer wants this link to open in a new browser tab. What is wrong with the attribute value, and what is the correct value?

Item 2 — CSS selector
highlight { background-color: yellow; }

A developer intends to style all elements with the class highlight. What is wrong with this selector? What does it actually target (if anything)? Write the corrected rule.

Item 3 — Heading structure
<h1>Computer Science Foundations</h1> then <h3>Chapter 20</h3> then <h2>Section 20.1</h2>

What problem does this heading order create? Who is affected by it?

Item 4 — Fragment identifier reasoning
"The #exercises at the end of the URL is sent to the server so it only returns the exercises section."

What is factually wrong about this explanation? How does the fragment identifier actually work?

Item 5 — HTTPS reasoning
"This site has HTTPS and a padlock, so it is completely safe and I can trust everything on it."

Identify what is correct in this statement and what is incorrect. What does HTTPS guarantee, and what does it not guarantee?

Chapter 20 Checkpoint

Chapter 20 Checkpoint
Complete without assistance — assesses all key concepts from Chapter 20
Section 1 — Vocabulary and Concepts
  1. Define the client-server model as applied to the web. Which software on your computer acts as the client?
  2. What is the difference between HTTP and HTTPS? What does TLS add to the connection?
  3. Explain the three roles of HTML, CSS, and JavaScript on a modern web page.
Section 2 — URL Analysis
  1. For this URL: https://shop.example.edu/products?category=textbooks&sort=price#results — identify the scheme, host, path, each query parameter, and the fragment. Which of these is never sent to the server?
  2. Explain why a URL path like /courses/intro-cs/chapter20 is preferable to /page?id=84729 even if both load the same page.
Section 3 — HTTP Status Codes
  1. What does a 404 status code mean? Does it mean the web server is offline?
  2. A server returns 301 with a Location header. What should the browser do, and why is this useful for users with bookmarks?
Section 4 — HTML, CSS, JavaScript
  1. Write valid HTML for: a level-2 heading reading "20.6 HTML as Structure", followed by a paragraph with one sentence of your choice, followed by an unordered list of three items (HTML, CSS, JavaScript).
  2. A CSS rule reads: .highlight { color: red; font-weight: bold; } — What type of selector is this? How would you apply it to a specific word in a paragraph?
  3. What is the DOM? Why does JavaScript need it to change what a user sees on screen?
Section 5 — Accessibility and Error Analysis
  1. Name the four POUR principles and give one concrete example of a web design decision that fulfills each.
  2. A developer writes <img src="diagram.png">. Identify the missing accessibility feature and explain who is harmed by the omission.

Real-World Applications

  1. E-commerce. When you add a product to a cart and the cart count updates without the page reloading, which web technology is responsible? Explain the general mechanism.
  2. Accessibility audit. You visit a website and notice: no visible labels on form fields, images with no alt text, and headings jumping from <h1> directly to <h5>. List three types of users who would experience problems, and for each, explain which specific issue affects them.
  3. Search and discovery. A new blogger publishes their first article. Explain why it may not appear in search engine results immediately. What factors might help search engines discover it faster?
  4. Security at checkout. A friend says: "I don't need HTTPS on my recipe website — nothing sensitive happens there." Is this reasoning sound or flawed? Make a case for using HTTPS on every page of any website.
  5. Responsive design failure. A student loads a school's website on a phone and finds the text is tiny, columns are too narrow to read, and buttons are hard to tap. What is the probable cause, and what CSS technique should the developer have used?
  6. Global performance. A photo-sharing website serves users in Europe, Asia, and the Americas from a single server in New York. Users in Tokyo report slow image loading. What infrastructure solution would you recommend, and how does it work?

Mixed Review

These questions draw on Chapters 1–20.

  1. (Chapter 4) A web page contains an image with a file size of 2.4 megabytes. How many bytes is that? How many bits?
  2. (Chapter 13) A search engine builds a model of the web by crawling pages and recording which words appear on each page. In what sense is this model an abstraction? What real-world detail does it leave out?
  3. (Chapter 14) A web server stores files in a directory structure: public/pages/chapter20.html. If the server's document root is public, what path would a URL need to contain to request this file?
  4. (Chapter 19) A user's browser has the IP address of a web server but cannot connect. List three possible reasons at the network level why the connection might fail.
  5. (Chapter 21 preview) A web page asks you to log in. What is the minimum information a well-designed login form should require? What additional security mechanism, beyond a password, would significantly reduce the risk of account compromise?
Looking Ahead
Chapter 21: Cybersecurity Foundations

Chapter 20 described how the web works: how requests travel between browsers and servers, how pages are built from HTML, CSS, and JavaScript, and how web apps use APIs to exchange data. This understanding is essential for Chapter 21. Many of the concepts from this chapter — HTTP requests, HTTPS certificates, cookies, JavaScript, forms, and user accounts — are all targets that security practitioners must understand and protect. Chapter 21 will build directly on your understanding of how the web works to explain how it can be attacked and how those attacks are prevented, introducing threats, vulnerabilities, malware, phishing, authentication, authorization, encryption, backups, and defense in depth.

MGU Library Connection
  • Chapter 19: Networks and the Internet — prerequisite for this chapter
  • Chapter 21: Cybersecurity Foundations — builds directly on HTTP, HTTPS, and web concepts
  • Web Development Foundations (MGU Computer Science Series) — extends HTML, CSS, and JavaScript to full course depth
  • Appendix H: Networks and Web Reference — HTML, CSS, JavaScript, URLs, HTTP, clients and servers
  • MGU Companion: HTML/CSS/JavaScript Overview, Internet versus Web Guide, Web Request Diagram