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'.
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?
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.
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.
Hi, the website is www.kohls.com
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
But where is the link with the # in it? All I can see is this:
The # at the end of that link is a mistake.
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>
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.
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:
<a href="#top">Top of Page</a>
Top of Page
Your code is out of date. These days, use this:
... where element is any element (such as div etc.).
This topic is now closed. New replies are no longer allowed.