Loading...

Go Back

Next page
Go Back Course Outline

Html5 Full Course


Links and Navigation

HTML Links and Navigation Examples

This document demonstrates how to create and manage links and navigation on your web pages using HTML. You will find explanations along with live code examples below.

1. Creating Links

Basic anchor tag (<a>)

The anchor tag (<a>) is used to create hyperlinks in HTML. You can link to external pages or other internal pages.

<a href="https://www.example.com">Click here to visit Example Website</a>


Linking to Internal and External Pages

1. External Page Link:

<a href="https://www.google.com">Visit Google</a>

Output:

Visit Google

2. Internal Page Link:

<a href="AboutUs.html">About Us</a>

Output:

About Us

Using target="_blank" to Open in a New Tab

The target="_blank" attribute is used to open a link in a new tab.

<a href="https://www.example.com" target="_blank">Visit Example Website in New Tab</a>

2. Navigation Elements

<nav> tag for Navigation Menus

The <nav> element is used to group navigation links together, which helps organize the menu on your website.

<nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="AboutUs.html">About Us</a></li> <li><a href="help.html">Services</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav>

Creating Simple Navigation Bars

You can style navigation links into a horizontal bar using CSS.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Simple Navigation Bar</title> <style> nav ul { list-style-type: none; padding: 0; } nav ul li { display: inline-block; margin-right: 20px; } nav ul li a { text-decoration: none; color: #333; font-size: 18px; } nav ul li a:hover { color: #007BFF; } </style> </head> <body> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="AboutUs.html">About</a></li> <li><a href="help.html">Services</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav> </body> </html>


3. Anchor Links and IDs

You can link to specific sections within the same page using id attributes and anchor links <a>.

<a href="#section1">Go to Section 1</a> <h2 id="section1">Section 1: Introduction</h2> <p>This is the introduction section.</p>

Output:

Go to Section 1

Section 1: Introduction

This is the introduction section.

Go Back

Next page