HTML & CSS
How can I link from web page A to a specific place on web page B?
On web page B, give the element that you want to jump to an ID, eg <p id="somethingrandom">
(You can achieve the same effect by adding <a name="somethingrandom"></a>, but that is very old-fashioned and not recommended)
Then, on web page A, you add that onto the link with a hash, eg <a href="pageb.htm#somethingrandom">
Thanks for that help. It worked successfully.
Then I tried another link, from lower in the page to the top of that same page, using this code (without success):
<a href="#top">Learn More</a>
When I select the Learn More, I am directed to the home page.
Any additional help will be appreciated.
From what you've told us, that shouldn't happen. Your code looks exactly right, apart from being 10+ years out of date, so either your code doesn't say exactly what you've written here or there's something funny going on. Double check that you're looking at the right version of the page and clicking on the right link, and if it's still giving unexpected behaviour then post a link to the problem page here and we'll have a look at it.
Edit: just a thought, you haven't got a <base> element on the page or anything like that, have you?
Yes, you should use the same code as you used in the previous scenario. If you just want to link to the top of the page, choose an element at the top of the page and add an ID to it, such as
<header <font color='"#FF0000"'>id="top"</font>>
Sometimes the top element (or the body) has some fee space under the top of the page.
In that case, you can set the id="top" on the <html> tag, and you will go just to the border of the viewport, whatever margins or paddings are used.
Should work, got mine set like this. If you can't even click on link, make sure no borders of any blocks are overlapping the link(Had that happen to me, absolute position block element border was larger then the containing content and was invisible to the eye without the border: CSS style added.
<header id=top> .... </header>
<a href = "#top"> Link to top of page </a>
This topic is now closed. New replies are no longer allowed.