What does href="#" mean?

I’ve seen the code snippet href=“#” on a number of sites, used in anchors, links, navigation li lists. It looks like a named-anchor definition but without the name?! Does it mean “this page”, “the top of this page”, a dummy to satisfy syntax requirements? What does it do?
Thanks,
John

This is just a ‘‘null’’ value - which means the anchor will be seen as live (and would also enable use of the <title> tag), and should produce a hand pointer on hover - but it’s use will take the user back to the same page he is on. Sometimes a better option for a ‘‘live’’ link but one which goes nowhere is -

<a href=“javascript: void(0)”>I am a useless link</a>

A named anchor of course would be something like - <a name=“marker”></a> - that then called by a suitable link on the page to scroll down to the named anchor target <a href=“marker”></a> - or at the end of a full link - <a href=“http://www.mysite.com/apage.htm#marker”>Target page and target content position</a> In this case the pound sign is used other than on its own, as we saw in the ‘‘null’’ link example.

Thanks ChrisXPPro, your full, clearly expressed & prompt explanation is very much appreciated.
John

Glad it may have helped John. :slight_smile:

represents the start of a hash value. Strictly speaking it should have something following it (eg. #xx will link to the spot in the page that has id=“xx”). With most browsers if you don’t specify a value following it defaults to the top of the page.

It most certainly does NOT represent NULL in any way whatsoever. Anyone who thinks that is misusing the value.

Stu Phillips uses this in his offerings:

<a href="#nogo">

Always wondered why he added the “nogo” wording. Stephen, I think you’ve answered that question.

Just to make sure that the question is fully answered - that link goes to the <div id=“nogo”> tag in the same page.

You can also link to that spot in the page from another page by specifying the page in front of the hash - eg. <a href=“nextpage.html#nogo”>

I always use the practice of having an ID of “top” at the first element occurrence in the visual hierarchy, that way I can link to the top of the page if required without depending on the hash alone (as it’s more semantic). Though no-one should use that horrible JavaScript: void pseudo. :slight_smile:

Hello,

href=“#” is used to active/enable the link on your page.

The anchor identifier also known as (Fragment ID) is supposed to have a UNIQUE value and follow the ending “#”; not be the lone hash “#” on its own (i.e. the Fragment ID omitted completely), or it is basically writing poppycock and shouldn’t do anything sensible at all.

It most certainly does NOT represent NULL in any way whatsoever. Anyone who thinks that is misusing the value.

felgall - I am suitable admonished! I guess I have just been regarding the # alone as a null for practical purposes in an anchor … your point sir is taken.

Why didn’t you read the thread first before posting incorrect information. There is a correct description of what the # means above your incorrect one.