Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
On many websites I see links that have href="#". What does it mean? What is it used for?

What I have tried:

i searched many sites, but cant understand the meaning.
Posted
Updated 17-Oct-16 22:37pm

An HREF starting with '#' is a link within the page - to a section head, normally.
If it's on it's own, with no text to ID the DIV to link to, it means "top of page".
The page will scroll so that the link destination is visible.
 
Share this answer
 
Comments
CPallini 18-Oct-16 4:39am    
5.
It basically means "navigate to a location on this page", or in other words "stay here". It's a way of making a link that doesn't go anywhere, and it's used when you want to use javascript to handle the click event of the link rather than browser navigation, however to consider the tag as being a link it needs something in the href so "#" makes it a link that goes nowhere. It also means that if javascript is disabled nothing untoward happens if the user clicks the link, it just does nothing.

To go into more detail, the "#" notation is a page anchor. You can "name" parts of the page and navigation to that part of the page using the anchor name, so if I have a link like; "mypage.html#results" and on mypage there is an anchor on the page called "results"

<a name="results">


then clicking on that link will take the user to mypage and scroll down directly to the results anchor.
 
Share this answer
 
Comments
CPallini 18-Oct-16 4:40am    
5.
ZurdoDev 18-Oct-16 7:00am    
Correct explanations. +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900