The "HT" in HTML stands for HyperText, and the ability to link documents together is its superpower. We do this with the anchor tag: <a>.
Analogy: The <a> tag is like an envelope. The text inside is the letter, but it's useless without an address. The href attribute is the mailing address written on the front.
The href Attribute
The href (hypertext reference) attribute specifies the destination URL.
1. External Link: (To another website)
Use the full URL.
<a href="https://www.google.com">Search on Google</a>
2. Relative Link: (To another page on your site)
This is the best practice for internal links.
<a href="/about.html">Learn More About Us</a>
3. Anchor/Bookmark Link: (To a specific section on the same page)
This is a two-step process. First, mark the destination with a unique id.
<h2 id="section2">Chapter Two</h2>
Then, create a link pointing to that id using a hash (#).
<a href="#section2">Jump to Chapter Two</a>
Best Practice Tip: When linking to an external website, add the target="_blank" attribute to make the link open in a new browser tab. This keeps the user on your site.
<a href="https://www.google.com" target="_blank">Search on Google</a>
What's Next: A page with just text and links is a bit boring. In the next lesson, we will learn how to bring our pages to life by adding images.