Programmer | DevTools & Open Source
Understanding URL Schemes & Protocols
Understand URI schemes, URLs, and communication protocols with practical HTML examples.
Have you ever wondered why HTML links use prefixes likehttps://,mailto:, andtel:?
You might have heard developers call these prefixes protocols. Although that terminology is common in everyday conversations, there’s an important technical distinction between a URI scheme and a communication protocol.
Let’s break it down with simple examples.
What Is a URI?
A Uniform Resource Identifier (URI) is a string that identifies a resource or indicates how it should be handled.
For example:
https://example.com
mailto:[email protected]
tel:+8801234567890
mongodb://localhost:27017/mydb
postgresql://USER:PASSWORD@localhost:5432/db
mysql://USER:PASSWORD@localhost:3306/mydb
These are all examples of URIs. They use different schemes for different purposes.
Security note: Never expose real database credentials in source code, logs, or public documentation. Use environment variables or secure configuration management.
graph TD
A[URI Examples] --> B["https://example.com
Scheme: https"]
A --> C["mailto:[email protected]
Scheme: mailto"]
A --> D["tel:+8801234567890
Scheme: tel"]
A --> E["mongodb://localhost:27017/mydb
Scheme: mongodb"]
style A fill:#1e293b,stroke:#58a6ff,stroke-width:3px,color:#e6edf3
style B fill:#0d1117,stroke:#58a6ff,stroke-width:2px,color:#e6edf3
style C fill:#0d1117,stroke:#ffd700,stroke-width:2px,color:#e6edf3
style D fill:#0d1117,stroke:#ff6b6b,stroke-width:2px,color:#e6edf3
style E fill:#0d1117,stroke:#a78bfa,stroke-width:2px,color:#e6edf3
What Is a URL?
A Uniform Resource Locator (URL) is a type of URI that identifies a resource by describing where it is located or how it can be accessed.
For example:
https://api.example.com/about
Here:
httpsis the scheme.api.example.comis the host (including subdomainapi)./aboutis the path.
graph TB
subgraph URL["Complete URL"]
direction LR
S["https"] --- D["://"] --- H["api.example.com"] --- P["/about"] --- Q["?page=2"] --- F["#section"]
end
S -.->|Scheme| S1["Identifies URI scheme"]
D -.->|Delimiter| D1["Separates scheme from
hierarchical part"]
H -.->|Host| H1["Subdomain + Domain"]
P -.->|Path| P1["Resource location"]
Q -.->|Query| Q1["Parameters"]
F -.->|Fragment| F1["Page section"]
style S fill:#0d1117,stroke:#3fb950,stroke-width:3px,color:#3fb950
style D fill:#0d1117,stroke:#8b949e,stroke-width:2px,color:#8b949e
style H fill:#0d1117,stroke:#58a6ff,stroke-width:3px,color:#58a6ff
style P fill:#0d1117,stroke:#ffd700,stroke-width:3px,color:#ffd700
style Q fill:#0d1117,stroke:#a78bfa,stroke-width:3px,color:#a78bfa
style F fill:#0d1117,stroke:#ff6b6b,stroke-width:3px,color:#ff6b6b
style S1 fill:#161b22,stroke:#3fb950,color:#8b949e
style D1 fill:#161b22,stroke:#8b949e,color:#8b949e
style H1 fill:#161b22,stroke:#58a6ff,color:#8b949e
style P1 fill:#161b22,stroke:#ffd700,color:#8b949e
style Q1 fill:#161b22,stroke:#a78bfa,color:#8b949e
style F1 fill:#161b22,stroke:#ff6b6b,color:#8b949e
style URL fill:#1e293b,stroke:#58a6ff,stroke-width:2px,color:#e6edf3
Every URL is a URI, but not every URI is necessarily a URL.
What Is a URI Scheme?
A URI scheme identifies the type of URI and determines how its syntax and meaning should be interpreted. The precise meaning and behavior are defined by the relevant scheme specification.
It appears before the first colon (:).
Examples:
| Scheme | Example | Purpose |
|---|---|---|
https | https://example.com | Secure web access |
http | http://example.com | Web access |
mailto | mailto:[email protected] | Email handling |
tel | tel:+8801234567890 | Telephone number handling |
ftp | ftp://example.com/file.txt | File transfer resource (limited browser support) |
ftps | ftps://example.com/file.txt | Secure file transfer (limited browser support) |
file | file:///home/user/file.txt | Local file reference |
ssh | ssh://example.com | SSH resource identification (client/tool specific) |
mongodb | mongodb://localhost:27017/mydb | MongoDB database connection |
postgresql | postgresql://USER:PASSWORD@<br>localhost:5432/db | PostgreSQL database connection |
mysql | mysql://USER:PASSWORD@<br>localhost:3306/mydb | MySQL database connection (client/library specific) |
A scheme doesn’t necessarily represent a communication protocol. For example,mailto:identifies an email address for an appropriate handler; it doesn’t itself define how email is transmitted.
The scheme specification defines the syntax and semantics for that type of URI.
What Is a Protocol?
A protocol is a set of rules that defines how systems communicate or exchange data.
Important: Protocols are the actual rules governing communication. They define formats, sequences, error handling, and data transmission methods.
Common examples include:
HTTP (Hypertext Transfer Protocol): Defines how web clients and servers exchange requests and responses.
HTTPS (Hypertext Transfer Protocol Secure): HTTP communication secured with TLS, or HTTP/3 secured through QUIC’s security mechanisms.
TCP (Transmission Control Protocol): Provides reliable, ordered delivery of data between endpoints.
TLS (Transport Layer Security): Provides encryption, authentication, and integrity for supported connections.
SSH (Secure Shell): Defines secure remote access and other secure communication capabilities.
Protocols define communication behavior. A URI scheme identifies how a URI should be interpreted or used.
The key difference: A scheme identifies the type and interpretation of a URI, while a protocol defines the actual rules for communication.
Scheme-to-Protocol Mapping
Here’s how common URI schemes relate to communication:
| Scheme | Typical Communication | Notes |
|---|---|---|
https | HTTP secured with TLS, or HTTP/3 over QUIC | Modern browsers may use HTTP/3 with UDP instead of TCP |
http | HTTP, typically over TCP | HTTP/3 uses QUIC and is ordinarily accessed via httpsin browsers |
mailto | Delegates email handling to an application | Email client may use SMTP, IMAP, POP3 |
tel | Delegates telephone handling to an application | Phone system handles call protocols (SIP, etc.) |
ftp | FTP over TCP | File transfer with authentication |
ftps | FTP secured with TLS/SSL over TCP | Secure FTP with encryption |
ssh | SSH over TCP | Secure shell for remote access |
ws | WebSocket (upgraded from HTTP) over TCP | Real-time bidirectional communication |
wss | WebSocket secured with TLS over TCP | Secure WebSocket connections |
mongodb | MongoDB Wire Protocol over TCP | Database-specific protocol |
postgresql | PostgreSQL Protocol over TCP | Supports bothpostgresql://and postgres://schemes |
mysql | MySQL Client/Server Protocol over TCP | Used by certain MySQL clients and libraries |
file | Local filesystem access | OS handles file I/O, no network protocol |
data | Data embedded directly in the URI | No protocol needed, data is in the URI itself |
Key insight: Most schemes that involve network communication use multiple protocols working together in layers. For example, HTTPS typically uses HTTP for application logic, TLS for encryption, and TCP for reliable delivery (though HTTP/3 uses QUIC over UDP).
Scheme vs. Protocol: What’s the Difference?
Here’s the critical distinction many developers miss:
| Feature | URI Scheme | Communication Protocol |
|---|---|---|
| What it is | An identifier or label | A set of communication rules |
| Role | Tells software how to interpret a URI | Defines how data is actually transmitted |
| Examples | https,mailto,tel,ftp | HTTP, SMTP, TCP, TLS |
| Where you see it | At the start of URIs (before :) | Behind the scenes in network communication |
| Analogy | A label that identifies how to handle something | The rules that govern how systems communicate |
The distinction becomes clearer when you comparemailto:with HTTPS.
Example A:https://
<a href="https://example.com">Visit website</a>
- Scheme:
https(identifies the URI scheme) - What it means: Indicates that the resource is accessed using secure HTTP communication
- Communication: HTTP over TLS, or HTTP/3 over QUIC
- The connection: The browser uses the scheme to determine how to access the resource
When a browser seeshttps://, it knows to establish a secure HTTP connection.
Example B:mailto:
<a href="mailto:[email protected]">Send email</a>
- Scheme:
mailto(the identifier) - What it means: “This is an email address, open an email handler”
- Protocol used: None directly - the scheme delegates to an email application
- The connection: When you send the email, protocols like SMTP handle the transmission
Example C:tel:
<a href="tel:+8801234567890">Call us</a>
- Scheme:
tel(the identifier) - What it means: “This is a telephone number”
- Protocol used: Delegates to the phone system
- The connection: Telephony protocols (SIP, cellular protocols, etc.) handle the actual call
How Does This Relate to HTML’shrefAttribute?
The HTMLhrefattribute specifies the destination of a link. That destination can use different URI schemes.
<!-- Navigate to a website -->
<a href="https://example.com">Website</a>
<!-- Open an email handler -->
<a href="mailto:[email protected]">Email</a>
<!-- Open a telephone handler -->
<a href="tel:+8801234567890">Phone</a>
<!-- Navigate to a section on the current page -->
<a href="#features">Features</a>
<!-- Navigate to a relative path -->
<a href="/about">About</a>
Not everyhrefbegins with an explicit scheme. For example,/aboutis a root-relative URL, while#featuresis a fragment reference.
Also, a link’s scheme doesn’t guarantee that the requested action will succeed. The relevant application, handler, or network service must be available and support it.
A Simple Way to Remember
Think of it this way:
URI: An identifier for a resource.
URL: A URI that identifies a resource by location or access mechanism.
Scheme: The label before the colon that says “this is how you should interpret this URI.”
Protocol: The actual rules and procedures that govern how systems communicate.
href: The HTML attribute used to specify a link’s destination.
Real-World Analogy
Think of a scheme like a label on a package:
- The label
mailto:says “this contains an email address” - But it doesn’t deliver the email - that’s done by email protocols (SMTP, etc.)
Think of a protocol like postal service rules:
- They define exactly how mail gets delivered
- Package sorting, delivery routes, confirmation procedures, etc.
When someone says “https://is a protocol,” they usually mean “it uses the HTTPS protocol” - which is close enough in casual conversation. But now you know the technical distinction: https://is a scheme that indicates the HTTPS protocol should be used.
Conclusion
Schemes and protocols are related, but they serve different purposes. Schemes identify how a URI should be interpreted, while protocols define the rules for communication and data exchange.
Understanding this distinction makes HTML links, web addresses, and networking terminology easier to reason about—and helps you use technical terms more accurately in your code and documentation.
Further Reading
- RFC 3986: Uniform Resource Identifier (URI): Generic Syntax - The official specification for URIs
- IANA URI Schemes Registry - Complete list of registered URI schemes