Alcaeus D
Alcaeus D

Reputation: 258

URL parameters ending with '#'

What is the purpose of using # at the end of a URL with parameters ?

i.e. https://www.example.com/mypage?name=George&profession=Engineer#

I have noticed that in my browser if my URL is like this:

https://www.example.com/mypage?name=George&profession=Engineer (without #)

and I hit Enter then I'm redirected.

But if my URL ends with # and I hit enter, nothing happens.

Upvotes: 0

Views: 2416

Answers (1)

Quentin
Quentin

Reputation: 943185

The # indicates the start of the fragment identifier. This follows the query string and is not part of it.

It causes the browser to navigate to the element with the matching ID in the page the previous sections of the URL refer to.

http://example.com/foo/?bar=123#baz

… will link to the element with id="baz (such as <section id="baz">...</section>) in http://example.com/foo/?bar=123


The page doesn't reload when you just add a # and press enter because the browser knows it already has the page loaded and will just scroll to the matching id (or the top of the page in this case because there is no matching id).

Upvotes: 2

Related Questions