VCF

Unit 1 · How the web works

What the # part of a URL does

The fragment, everything after #, stays in your browser. It never goes to the server; it only tells the browser which spot on the current page to scroll to.

The mix-up

What people often think

“The part after # is another page.”

What the tutor says

The # part never leaves your browser. It only scrolls to a spot on the page that already loaded.

If the server never sees #reviews, how could it send a different page for it?

How it works

In cornerbakery.ca/menu#reviews, the server receives a request for /menu and nothing else. The browser loads that page, then looks for the element with id="reviews" and scrolls to it.

Changing only the fragment does not load a new page, because the server would see the same /menu either way. That is also why # hides nothing: it does not make a page secret or secure, it just keeps that part of the address out of the request.

An example

What worksHTML
<a href="#reviews">Jump to reviews</a>
...
<section id="reviews">...</section>
A fragment link scrolls within the page; no request goes out.

Close cousins of this mix-up

The tutor watches for these in the same lesson.

  • “Changing the # part loads a different page from the server.”

    The server sees /menu either way. Your browser just jumps to a different spot on the same page.

  • “The # symbol hides a page or makes it secure.”

    The # hides nothing. It just stops that part of the address from reaching the server.

Practise it with a tutor watching

Parts of a URL

Name each part of a URL and say which parts reach the server.

15 minutes See it Build it Break it Say it
Start the lesson

Free, no account needed.