In HTML, you can also create a link to a specific section on a page. It’s similar to creating a link to the top of the page, but requires an extra step.
Steps
Add heading
It’s common to link to a heading when creating a link to a specific section. Create a new line above the last paragraph. Type h2 and press Tab on that line to generate an <h2> element.
Type Last section in between the <h2> tags.
If you check the preview, you should see a heading appear that says Last section.
Add id attribute
We need to add a new attribute to the <h2> element. Inside the opening tag, type a space, then type id and press Tab to generate the equals sign and quotes.
Next we need to give the id a value. This is important because we’ll use it again for the href value in our link. Let’s call this one last-section. Note: If your id contains more than one word, use a dash to separate the words.
If you check the preview, the heading should still say the same. The id attribute should not have an effect on the way it looks.
Add link
Now let’s go back to the top of our page. After our external link, type a and press Tab.
In the href value, type #last-section. Just like with creating a link to the top, we use a hashtag at the beginning of the value.
If you check the preview, you should see a new link appear.
Click and drag on the divider to make the preview narrow. Then try clicking on the link in the preview. The preview should jump to the last section.
This was a very basic example, but you can find a more realistic example by looking at the table of contents of this Wikipedia article on HTML.
End
The difference between linking to a specific section and linking to the top is that we didn’t need to create an id to link to the top.
Final code
Here is the code that should be in between the <body> tags.