Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what does a href=# mean?

Status
Not open for further replies.

duckyboyz

Programmer
Mar 28, 2002
57
US
what does this syntax do?

ex.
<a href=# id="lnkReports" >MTSA Reports</a>

i don't understand what "href=#" do.
 
It should be correctly as (quotes around the #):
<a href="#" id="lnkReports" >MTSA Reports</a>

This creates a text link to the top of the current page. Lets say you had scrolled down a long page, clicking this link would bring you back to the top.
 
When you define anchor tags in your code such as this:

<a name="section4">This is section 4</a>

And then you try to link to it from the same page, like this:

<a href="#section4">Go To Section 4</a>

Then, when you click the link, it will scroll up or down (depending on your current location in the document) to place "This is section 4" at the top of the screen.

So, when you use it like this:

<a href="#">Click here...</a>

Then, clicking on it will do nothing. This is usually a way to add javascript to a link's onclick event.

<a href="#" onclick="alert('you clicked me');">Click Here...</a>

*cLFlaVA
----------------------------
Ham and Eggs walks into a bar and asks, "Can I have a beer please?"
The bartender replies, "I'm sorry, we don't serve breakfast.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top