The course is part of this learning path
One of the best parts of HTML is its ability to hyperlink to pretty much anything. This lets you link to external websites, and pages within your own site easily. In this module, you’ll learn how to hyperlink and how to use named anchors to move around pages. After this, you’ll learn about the difference between absolute and relative URLs, and when to use them. We’ll end the module off with a discussion on how to include mailto links on your sites.
While you can use the anchor element with the href attribute to hyperlink to external websites and resources, it's also actually possible to hyperlink to other elements within your own website. You can do this using named anchors and the id attribute. The basic idea is that you use the anchor elements with the id attribute to define a named anchor. Then later on if you want to hyperlink to that named anchor, you can use an anchor with an href attribute whose value is an id of a named anchor.
Let's have a look at how this works in practice. So first off let's say I want to be able to jump to a point to my page called start. First off I'll need to create an element that has an id attribute. So I'll open the tag then add an id to the element which is start in this case, great. Now if I want the user to be able to get to this point at different points in the page, all I need to do is use my anchor elements but this time with an href attribute and a hash tag before the name like this.
In the browser, clicking on the top of the page link will now display the h1 tag at the top of the page, awesome. Let's say you have two pages though and you want to be able to hyperlink to a named anchor on another page, how do you think you'd do it? If you thought you'd use an href attribute, you're right.
First open the anchor tag with the href attribute then you'll add the domain of the page probably something like www.somedomainname.com, then add a hash tag followed by the name of the anchor. And that's all for this video. As you can see named anchors give you a lot of flexibility. Using them you can link between any point in your page or between other pages.
Ed is an Outstanding Trainer in Software Development, with a passion for technology and its uses and holding more than 10 years’ experience.
Ed is responsible for delivering QA’s Programming Foundations course using the Eclipse IDE. His skillset extends into the DevOps sphere, where he is able to deliver courses based around Agile/Scrum practices, version control, and CI/CD.