Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is it when a link has a pound "#" sign in it

Tags:

html

I have inspected some sites and they have a pound(#) sign in the url. What does it do?

 <a href="#" >Link name</a>
like image 628
Luke101 Avatar asked May 10 '10 03:05

Luke101


People also ask

What does the pound sign mean in HTML?

This answer is not useful. Show activity on this post. The pound sign ( # ) indicates to locate an anchor on the page. For example, if you include this somewhere on the page: <a name="foo"></a>

What is a Hashtag link?

Anchor (hash link) is a bookmark link, which, when clicked, forces the server to redirect page to the desired page or “anchored” place. The name “hash-link” is used because it includes the symbol “#”.

What is the use of symbol in link URL?

It is not a simple regular character but has a special function. So first of all, it is called a named anchor or sometimes as a fragment. Named anchor or fragment is used to link to the part of the same web –page.


3 Answers

It's a "fragment" or "named anchor". You can you use to link to part of a document. Typically when you link to a page, the browser opens it up at the top of the page. But you link to a section half-way down, you can use the fragment to link to that heading (or whatever).

If there is no <a name="whatever"/> tag within the page, then the browser will just link to the top of the page. If the fragment is empty, then it will also just link to the top of the page.

For a fragment only <a href="#">Link name</a>, then that's just a link to the top of the current page.

You often see that kind of link used in conjuction with javascript. Standards compliant HTML requires a href attribute, but if you're planning to handle the request with javascript then "#" serves as a reasonable place holder.

like image 197
Dean Harding Avatar answered Sep 18 '22 16:09

Dean Harding


... just to add a few extra useful tips.

You can access and change it with document.location.hash in JavaScript.

It can point to a named anchor (e.g. <a name="top"></a>) or to an element with a corresponding id (e.g. <div id="top"></div>).

Seeing one on its own (e.g. <a href="#" onclick="pop()">popup</a>) generally means a link is being used to run JavaScript exclusively. This is bad practice.

Any a element should have a href that points to a valid resource. If one does not exist, consider using another element, such as button.

like image 36
alex Avatar answered Sep 19 '22 16:09

alex


The pound sign (#) indicates to locate an anchor on the page. For example, if you include this somewhere on the page:

<a name="foo"></a>

or, more recently:

<div id="foo">*part of page*</div>

and then you click on a link on the page that has the href #foo, it will navigate to the anchor with the name or div with the id foo.

However, if you just have the href #, it will lead to the top of the page.

like image 37
ElectroBit Avatar answered Sep 18 '22 16:09

ElectroBit