SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what does <a href="#"> means and how it works?

    Hi i came accross a piece of code as follows. <a href="#">Wedding Wishes Registry</a> . How <a href="#"> will work. when i tap on the link it is taking me to new page. How is that possible as there was no target page mentioned in 'href'.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    54
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hey agkrishna and welcome to the Forum.

    The <a href="#"> is how you would place a link using HTML. If the end user clicks on the text, in this case "Wedding Wishes Registry", they would be directed to the place that the href has specified. In this case, the user wouldn't be directed as "#" is what you use when building a site before applying links.

    As you have said this does re-direct you, can you provide the website so we can take a look?

    Cheers

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,620
    Mentioned
    413 Post(s)
    Tagged
    7 Thread(s)
    Quote Originally Posted by agkrishna View Post
    How <a href="#"> will work.
    Yes, all that will do is take you to the top of the current page, so it's useless. The # needs to be replaced by the URL of the target page. # can also be used to link to other parts of the same page, but it doesn't sound like this is the purpose here.

  4. #4
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,011
    Mentioned
    57 Post(s)
    Tagged
    0 Thread(s)
    Until a link is actually made programmers will sometimes put the # in as a placeholder. It's possible the placeholder escaped to the wild. Also, it is possible they have some JS click event to send you to the real link - but that's a clumsy way to do it since it breaks if JS isn't available.

  5. #5
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, the website is www.kohls.com
    Attached Images Attached Images

  6. #6
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,742
    Mentioned
    32 Post(s)
    Tagged
    1 Thread(s)
    detailed answer:

    # is called an anchor (or hash...). so the link is pointing to an anchor or ID on a page, or it would be if the # had some text after it. As it stands it goes nowhere because it doesn't have text after it.

    In case you are wondering WHY a link would go nowhere, they are probably using "#" as a placeholder. An anchor tag would not behave as an anchor tag w/o the HREF, but setting an actual HREF might send you off the page each time you are testing. That is annoying, so "href='#'" works out nicely.

    Addition tips. you can actually use # to jump to a specific part of ANOTHER page. for example let say somewhere in you "about.html" page you have an element with an ID= "theresMore". From any OTHER PAGE, you can link directly to that part of the page with "href=about.html#theresMore" ( do note that would be a relative url just for the example)



    hope that helps

  7. #7
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,620
    Mentioned
    413 Post(s)
    Tagged
    7 Thread(s)
    Quote Originally Posted by agkrishna View Post
    Hi, the website is ...
    But where is the link with the # in it? All I can see is this:

    Code:
    <a href="/kohlsStore/ourbrands/lclaurenconrad.jsp#">
    The # at the end of that link is a mistake.

  8. #8
    Non-Member
    Join Date
    Apr 2013
    Location
    Jaipur, India
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It means "Render a hyperlink that takes the visitor to the top of the page and label it with the, distinctly uninformative, text Click here"
    It work :- <a href="submit.php"><input type="button" value="Submit" class="button" /></a>

  9. #9
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,234
    Mentioned
    47 Post(s)
    Tagged
    1 Thread(s)
    The above code (<a href="wherever"><input type="button"></a>) will not work in IE 6-8, unless someone's given the anchor an onclick event.

  10. #10
    Non-Member
    Join Date
    Apr 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by agkrishna View Post
    Hi i came accross a piece of code as follows. <a href="#">Wedding Wishes Registry</a> . How <a href="#"> will work. when i tap on the link it is taking me to new page. How is that possible as there was no target page mentioned in 'href'.
    when you linking within the same document, the A element is set as follows.

    Eg: <a name="top"></a>

    Now make a hyperlink that points to the bookmark:

    Code

    <a href="#top">Top of Page</a>

    Output

    Top of Page

    <snip>
    Last edited by TechnoBear; May 2, 2013 at 05:53. Reason: Please wait 90 days for a real signature

  11. #11
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,620
    Mentioned
    413 Post(s)
    Tagged
    7 Thread(s)
    Quote Originally Posted by albert_mendosa View Post
    when you linking within the same document, the A element is set as follows.

    Eg: <a name="top"></a>
    Your code is out of date. These days, use this:

    Code:
    <element id="top">
    ... where element is any element (such as div etc.).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •