Links and Bookmarks
What Is It?
A link takes the reader to another page or to a section on the same page.
What the Tags Mean
a: creates a link.href: says where to go.id: names a destination on the page.
Example 1
Save each example as index.html and open it in your browser. Each code block is a complete page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Links and Bookmarks</title>
</head>
<body>
<a href="#about">Read about me</a>
<h2 id="about">About me</h2>
<p>I am learning HTML.</p>
</body>
</html>Browser preview
What you see: Clicking the link jumps to About me.
Example 2: Another Use
The next example opens contact details on the same page. A separate page would use a relative path such as contact.html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Links and Bookmarks</title>
</head>
<body>
<a href="#contact">Contact details</a>
<section id="contact"><h2>Contact details</h2><p>Visit the club on Saturday at 10 am.</p></section>
</body>
</html>Browser preview
Simple Tip
Use clear link text such as Contact details instead of Click here.
Try It Yourself
Add a link that jumps to a heading named My hobbies.