HTML / HTML Links and Navigation

Creating Internal and External Links

In this tutorial, you'll learn how to create internal and external links using the <a> tag. Internal links lead to content within your own site, while external links lead to other…

Tutorial 3 of 5 5 resources in this section

Section overview

5 resources

Teaches how to create hyperlinks and navigation menus in HTML.

1. Introduction

2. Step-by-Step Guide

Examples:

  1. Internal Link: <a href="#section1">Go to Section 1</a>
  2. External Link: <a href="https://www.example.com">Visit Example.com</a>

Best practices and tips:

  1. Always use meaningful anchor text that gives a clear idea of what the link is about.
  2. For external links, it is generally a good practice to open the link in a new tab. This can be done by adding the target="_blank" attribute to the a tag.

3. Code Examples

Example 1: Internal Link

<!-- This is the link -->
<a href="#section1">Go to Section 1</a>

<!-- This is the destination -->
<div id="section1">
  <h2>Section 1</h2>
  <p>This is Section 1.</p>
</div>
  • The #section1 in the href attribute is the destination of the link.
  • When you click on "Go to Section 1", the browser will scroll to the element with an id of "section1".
  • The expected result is that the page will scroll to "Section 1".

Example 2: External Link

<a href="https://www.example.com" target="_blank">Visit Example.com</a>
  • The href attribute points to "https://www.example.com", which is the destination of the link.
  • target="_blank" makes the link open in a new tab.
  • The expected result is that a new tab will open and load "example.com".

4. Summary

5. Practice Exercises

Exercise 1: Create an internal link that navigates to a section at the bottom of the page.
Solution:

<a href="#bottom">Go to Bottom</a>

<div id="bottom">
  <h2>Bottom of the Page</h2>
</div>

Exercise 2: Create an external link that opens in a new tab.
Solution:

<a href="https://www.google.com" target="_blank">Open Google</a>

Exercise 3: Create a navigation bar using internal links.
Solution:

<nav>
  <a href="#home">Home</a> |
  <a href="#about">About</a> |
  <a href="#contact">Contact</a>
</nav>

<div id="home">
  <h2>Home</h2>
</div>

<div id="about">
  <h2>About</h2>
</div>

<div id="contact">
  <h2>Contact</h2>
</div>
  • This exercise combines multiple internal links to create a navigation bar.
  • Each link leads to a different section on the page.

Related topics

Keep learning with adjacent tracks.

View category

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

AES Encryption/Decryption

Encrypt and decrypt text using AES encryption.

Use tool

URL Encoder/Decoder

Encode or decode URLs easily for web applications.

Use tool

WHOIS Lookup Tool

Get domain and IP details with WHOIS lookup.

Use tool

Case Converter

Convert text to uppercase, lowercase, sentence case, or title case.

Use tool

JavaScript Minifier & Beautifier

Minify or beautify JavaScript code.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help