1.1 Introduction to the Web
Introduction
Every day, we use websites such as Google, YouTube, Facebook, Amazon, and Wikipedia. Behind every website is a combination of technologies that allows computers to communicate over the Internet.
Before learning HTML, CSS, JavaScript, and modern web frameworks, it is important to understand how the Web works and how a webpage travels from a server to your browser.
By the end of this lecture, you should understand:
- What the Internet is
- The difference between the Internet and the World Wide Web
- How computers communicate
- How data travels across the Internet
- The role of IP addresses and DNS
- How browsers communicate with web servers
- How a webpage is loaded
The Internet
The Internet is a global network that connects billions of computers and devices around the world.
It allows devices to exchange information regardless of their physical location.
Today, we use the Internet to:
- Visit websites
- Watch videos
- Send emails and messages
- Download files
- Play online games
- Attend online classes
- Use cloud applications
The Internet is the infrastructure that makes all of these services possible.
Internet vs World Wide Web
Many people think the Internet and the World Wide Web (WWW) are the same, but they are different.
- The Internet is the global network of connected computers.
- The World Wide Web (WWW) is a collection of websites and webpages that run on the Internet.
The Web is only one service provided by the Internet.
Other Internet services include:
- FTP (File Transfer Protocol)
- Video Calling
- Online Gaming
- Cloud Storage
Simple Analogy
Internet = Road Network
World Wide Web = Cars travelling on those roads
Or,
Internet = Infrastructure
Web = Websites running on that infrastructure
How Computers Communicate
When you open a website, your computer does not communicate directly with the destination computer.
Instead, data passes through many networking devices called routers.
A router's job is to:
- Receive data
- Determine the best route
- Forward data to the next destination
Example
Computer
↓
Router
↓
Router
↓
Router
↓
Server
If one route becomes unavailable, routers automatically choose another route.
This makes the Internet reliable and efficient.
Packets
Large files are not sent all at once.
Instead, data is divided into smaller units called packets.
Example
Photo
↓
Packet 1
Packet 2
Packet 3
Packet 4
Each packet contains:
- Source Address
- Destination Address
- Data
- Sequence Number
- Error Checking Information
Packets may travel through different routes before reaching their destination.
The receiving computer reassembles all packets into the original file.
TCP/IP
Computers communicate using a standard set of rules called TCP/IP.
TCP/IP consists of two main protocols:
- Internet Protocol (IP)
- Transmission Control Protocol (TCP)
Internet Protocol (IP)
Every device connected to the Internet has a unique IP Address.
Examples:
192.168.1.10
8.8.8.8
An IP address identifies where data should be sent.
IPv4
IPv4 uses 32 bits and contains four numbers separated by dots.
Example:
192.168.0.1
Each number ranges from:
0–255
IPv4 supports approximately 4.3 billion unique addresses.
IPv6
Because IPv4 addresses are limited, IPv6 was introduced.
IPv6 uses 128 bits, allowing an enormous number of unique addresses.
Example:
2001:0db8:85a3::8a2e:0370:7334
Transmission Control Protocol (TCP)
TCP ensures reliable communication.
Its responsibilities include:
- Breaking data into packets
- Tracking packet order
- Detecting missing packets
- Requesting lost packets again
- Reassembling packets correctly
Without TCP, files could arrive incomplete or in the wrong order.
Ports
A single computer can run many Internet services at the same time.
Ports help identify which service should receive incoming data.
Common Ports
| Port | Service |
|---|---|
| 80 | HTTP |
| 443 | HTTPS |
| 21 | FTP |
| 22 | SSH |
| 25 | SMTP |
When data is transmitted, it includes:
- Source IP Address
- Destination IP Address
- Port Number
This ensures data reaches the correct application.
DNS (Domain Name System)
Computers communicate using IP addresses.
However, humans prefer easy-to-remember names.
Instead of typing:
142.250.193.78
we type:
google.com
The Domain Name System (DNS) converts domain names into IP addresses.
Example
google.com
↓
DNS Server
↓
142.250.xxx.xxx
DNS is often called the Phonebook of the Internet.
DHCP (Dynamic Host Configuration Protocol)
When a device joins a network, it needs several network settings before it can communicate.
Instead of configuring these settings manually, DHCP automatically assigns:
- IP Address
- Subnet Mask
- Default Gateway
- DNS Server
Without DHCP, every device would need to be configured manually.
Web Browsers
A Web Browser is software that allows users to access websites.
Popular browsers include:
- Google Chrome
- Mozilla Firefox
- Microsoft Edge
- Safari
- Opera
A browser is responsible for:
- Sending requests to web servers
- Receiving responses
- Displaying HTML
- Applying CSS
- Executing JavaScript
Web Servers
A Web Server is a computer or software that stores websites and delivers them to users.
Examples include:
- Apache
- Nginx
- IIS
- Node.js
When a browser requests a webpage, the server sends the required files back to the browser.
HTTP and HTTPS
Browsers and servers communicate using HTTP.
HTTP (HyperText Transfer Protocol) defines how requests and responses are exchanged.
HTTPS (HyperText Transfer Protocol Secure) is the secure version of HTTP.
HTTPS encrypts communication using SSL/TLS, protecting sensitive information such as passwords and payment details.
URLs
A URL (Uniform Resource Locator) identifies the location of a resource on the Web.
Example
https://www.example.com/folder/file.html
Components of a URL
| Component | Description |
|---|---|
https:// |
Protocol |
www.example.com |
Domain Name |
/folder/ |
Path |
file.html |
Resource |
Common Top-Level Domains (TLDs)
.com.org.edu.gov.net
How a Website Loads
When you visit a website, several steps happen automatically.
1. User enters www.example.com
↓
2. Browser checks DNS
↓
3. DNS returns the server's IP address
↓
4. Browser connects to the server
↓
5. Browser sends an HTTP request
↓
6. Server processes the request
↓
7. Server returns HTML, CSS, JavaScript, Images
↓
8. Browser renders the webpage
This entire process usually takes only a few milliseconds.
Request and Response
The Web follows a Request–Response Model.
Request
The browser sends a request to the server.
Example:
GET / HTTP/2
Host: www.example.com
Meaning:
Please send me the homepage.
Response
The server processes the request and returns the requested resource.
Example:
HTTP/2 200 OK
Content-Type: text/html
The browser then renders the webpage for the user.
HTTP Status Codes
Every HTTP response includes a status code indicating the result of the request.
| Code | Meaning |
|---|---|
| 200 | OK |
| 301 | Moved Permanently |
| 302 | Found |
| 304 | Not Modified |
| 307 | Temporary Redirect |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 500 | Internal Server Error |
| 503 | Service Unavailable |
404 Not Found
The requested resource does not exist.
Example:
example.com/page-that-does-not-exist
500 Internal Server Error
An unexpected error occurred on the server while processing the request.
This usually indicates a problem with the application's code or server configuration.