World Wide Web: How Links and URLs Work

world wide web and how links and urls works

world wide web and how links and urls works

Every time you click a link or type an address into a browser, you’re using two of the most foundational concepts of the World Wide Web: hyperlinks and URLs (Uniform Resource Locators). This article explains, from first principles, what these actually are, how they’re structured, how they work technically under the hood, and how they fit into the broader system that makes “the web” work — with practical examples relevant to both everyday users and system administrators.

What Is the World Wide Web (And How Is It Different From “The Internet”)?

These terms are often used interchangeably, but they are not the same thing:

Email, FTP, and video calls also run over the Internet but are not part of the “Web” — they are separate applications using different protocols.

flowchart TD
    A[The Internet - Physical/Logical Network] --> B[Web - HTTP/HTTPS]
    A --> C[Email - SMTP/IMAP]
    A --> D[FTP]
    A --> E[Video Calls - RTP/WebRTC]

What Is a Hyperlink?

A hyperlink (or just “link”) is a piece of clickable content — usually text or an image — embedded in a web page, pointing to another URL. In HTML, links are created with the (anchor) tag:

About Us

When clicked, the browser navigates to the URL specified in the href attribute.

Types of Links

Link Type Example Behavior
Absolute Full URL, works from anywhere
Relative Relative to the current site’s root
Relative (same folder) Relative to the current page’s location
Fragment/anchor Jumps to an element within the same page
Mailto Opens the user’s default email client
Download Prompts a file download instead of navigation

Absolute vs. Relative URLs

This distinction matters a lot for web developers and system administrators managing websites.


Read more


Read more


Read more

Relative URLs are useful because they let you move an entire website between domains (e.g., from a staging server to production) without needing to rewrite every single link.

URL Encoding

URLs can only contain a limited set of safe characters. Anything else (spaces, special characters, non-ASCII text) must be percent-encoded.

Character Encoded Form
Space %20 (or + in query strings)
& %26
# %23
/ (when part of a value, not a path separator) %2F
é %C3%A9 (UTF-8 encoded)

Example:

https://example.com/search?q=linux%20tutorial

This represents a search query for “linux tutorial” (with an encoded space).

Python Example: Parsing a URL

Python’s standard library makes URL parsing straightforward — useful for scripts that process log files or scrape data:

from urllib.parse import urlparse, parse_qs

url = "https://www.example.com:443/products/shoes?color=red&size=10#reviews"
parsed = urlparse(url)

print("Scheme:", parsed.scheme)
print("Host:", parsed.hostname)
print("Port:", parsed.port)
print("Path:", parsed.path)
print("Query params:", parse_qs(parsed.query))
print("Fragment:", parsed.fragment)

Output:

Scheme: https
Host: www.example.com
Port: 443
Path: /products/shoes
Query params: {'color': ['red'], 'size': ['10']}
Fragment: reviews

Comparison: HTTP vs. HTTPS URLs

Aspect http:// https://
Default port 80 443
Encryption None TLS-encrypted
Data integrity Not guaranteed Verified via TLS
Browser trust indicators “Not secure” warning Padlock icon
SEO impact Slightly penalized by search engines Preferred/ranked higher

A Practical Example: Diagnosing a Broken Link

As a sysadmin or web developer, you’ll often need to check whether a URL is reachable using command-line tools:

curl -I https://www.example.com/products/shoes

Example output:

HTTP/2 200
content-type: text/html; charset=UTF-8

A 404 status means the page doesn’t exist (a “broken link”); a 301/302 means it redirects somewhere else; a connection timeout suggests a DNS or network problem.

curl -I https://www.example.com/old-page
# HTTP/2 301
# location: https://www.example.com/new-page

Real-World Use Case: Finding Broken Links on a Website

A simple Python script that checks a list of URLs and reports broken ones:

import requests

urls = [
    "https://www.example.com/",
    "https://www.example.com/about",
    "https://www.example.com/old-broken-page",
]

for url in urls:
    try:
        response = requests.head(url, timeout=5, allow_redirects=True)
        print(f"{url} -> {response.status_code}")
    except requests.RequestException as e:
        print(f"{url} -> ERROR: {e}")

Best Practices

  • Use HTTPS everywhere, not just for login pages — it protects all data in transit and is now effectively an industry baseline expectation.
  • Prefer relative URLs within your own site to make future domain migrations easier.
  • Always URL-encode dynamic values placed into query strings, to avoid malformed URLs or injection issues.
  • Keep URLs human-readable when possible (/products/red-shoes rather than /p?id=48291), which helps both usability and SEO.
  • Set up proper redirects (301) for moved pages instead of leaving broken (404) links behind.
  • Regularly audit your site for broken links, especially after content reorganizations.

Troubleshooting

Problem: Link works locally but breaks in production

Usually caused by mixing up relative and absolute paths, or by different base URLs between environments. Check the actual rendered href value in the browser’s developer tools.

Problem: curl shows a DNS resolution failure

curl: (6) Could not resolve host: example.com

This means DNS isn’t resolving the hostname. Check with:

nslookup example.com

Problem: URL with spaces or special characters doesn’t work

Ensure proper percent-encoding, especially in scripts or programmatically generated URLs. Use a library function (like Python’s urllib.parse.quote()) rather than manual string concatenation.

Problem: Fragment link (#section) doesn’t scroll to the right place

Confirm the target element actually has a matching id attribute in the HTML:

Reviews

Conclusion

URLs and hyperlinks are the connective tissue of the World Wide Web — a simple, elegant addressing system that lets any resource on the planet be referenced, shared, and retrieved with a single string of text. Understanding their structure (scheme, host, port, path, query, fragment), the resolution process behind the scenes (DNS, TCP, TLS, HTTP), and practical concerns like encoding and relative vs. absolute paths equips you to build, maintain, and troubleshoot web-facing systems with confidence.

Further Reading

Exit mobile version