HTML Links - Create Bookmarks
HTML links can be used to create bookmarks, so readers can jump straight to a specific part of a page.
Create a Bookmark in HTML
Bookmarks are useful on a very long page. To make one, first create the bookmark with an id attribute on an element (for example <h2 id="C4">Chapter 4</h2>), then add a link to it using href="#C4". When the link is clicked, the page scrolls to the element with that id.
You can also link to a bookmark on another page by putting the file name before the #.
Example
A link that jumps to Chapter 4 further down the same page.
Prompt
A long page that uses a bookmark: a link at the top "Jump to Chapter 4" that points to #C4, and further down an h2 with id="C4" reading "Chapter 4", with enough filler content between them that clicking the link scrolls down to the chapter.
Output: complete HTML page
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bookmark Jump</title>
</head>
<body>
<p><a href="#C4">Jump to Chapter 4</a></p>
<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>
<h2 id="C4">Chapter 4</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 5</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 6</h2>
<p>This chapter explains ba bla bla</p>
</body>
</html>
Bookmark on another page
Linking to a bookmark located on a different page.
index.html
<a href="html_demo.html#C4">Jump to Chapter 4</a>
Chapter Summary
To recap: use the id attribute (id="value") to define a bookmark on the page, and the href attribute (href="#value") to link to it.
HTML Link Tags
The main tag here is <a>, which defines a hyperlink.