Creating Links Between Pages - HTML

 

Links are essential for website navigation, allowing users to jump between pages easily. The <a> (anchor) tag is used to create hyperlinks.

Basic Link Syntax

<a href="page2.html">Go to Page 2</a>

Explanation

  • href (hyperlink reference) specifies the destination URL.
  • The text inside <a> becomes the clickable link.

Linking to External Websites

<a href="https://example.com" target="_blank">Visit Example</a>
  • target="_blank" opens the link in a new tab.

Linking to an Email

<a href="mailto:someone@example.com">Send an Email</a>
  • This opens the user's default email client.

Creating an Internal Navigation Menu

<ul>
  <li><a href="index.html">Home</a></li>
  <li><a href="about.html">About</a></li>
  <li><a href="contact.html">Contact</a></li>
</ul>
Run Code on FunProgramming

Fun Fact

Before CSS, people used tables for navigation menus (yikes!).

Linking to a Specific Section on a Page

<a href="#section2">Jump to Section 2</a>

<h2 id="section2">Section 2</h2>
  • The id attribute acts as an anchor target.

Conclusion

Mastering links in HTML ensures smooth navigation, making websites user-friendly and engaging! 

Post a Comment

0 Comments