html

What are the Steps to Generate Hyperlinks to Additional Web Pages Using HTML?

Generating hyperlinks to additional pages is an essential aspect of web development. By using it the developer can provide a seamless experience while providing users the freedom to traverse through multiple pages. It also helps in gaining more traffic by redirecting users to your page and improves engine optimization. Generating hyperlinks to additional pages can also be utilized for building advertising, references, a Navigation menu, etc.

This article demonstrates the steps to generate hyperlinks to additional web pages using HTML.

How to Generate Hyperlinks to Additional Web Pages?

The hyperlinks are generated by the utilization of anchor “<a>” tags. The path of additional web pages, relative to the main HTML page is passed as a parameter to the “href” attribute. The “hyperlinks” can be utilized to direct toward the section of the page.

Let us walk through step-by-step instructions to create navigation menu buttons to better understand generating hyperlinks to additional pages:

Step 1: Create a Structure for Navigation Menu

Inside the HTML file, create a parent “<div>” tag and assign it a class of “navigate”:

<body>

<div class="navigate">

<div class="nav-menu">

<a href="#">home</a>

</div>

<div class="nav-menu">

<a href="#">About</a>

</div>

<div class="nav-menu">

<a href="#">Services</a>

</div>

<div class="nav-menu">

<a href="#">Contact</a>

</div>

</div>

<h1> Welcome to linuxhint </h1>

<p> Example of Generating Hyperlinks to Additional Web Pages </p>

</body>

In the above code snippet:

  • First, the parent “div” element with a class of “navigate” is created.
  • Then, the multiple “<div>” tags are created having a class of “nav-item”. Inside each “<div>” tag, utilize the “<a>” tags and provide a dummy name to them.
  • After that, add some “<h1>” or “<p>” tags to make the content of the page.

After the execution of the above code snippet, the webpage looks like this:

The output shows that the links have been created on the webpage.

Step 2: Styling the Navigation Menu

Select the “div” elements and apply the following properties inside the “<style>” tag. These properties are utilized to enhance the visualization process:

<style>

.navigate {

display: flex;

list-style: none;

margin: 0;

padding: 0;

}

.nav-menu {

margin: 0 10px;

}

.nav-menu a {

color: blueviolet;

padding: 10px;

background-color: sandybrown;

text-decoration: none;

}

.nav-menu a:hover {

color: sandybrown;

background-color: transparent;

border: 2px solid blueviolet;

text-decoration: none;

}

</style>

The properties utilized in the above code snippet are described below:

  • First, set the values of “flex” and “0” to the “display” and “margin, padding” properties, respectively.
  • Next, assign a value of “10px” to the margin-left and right properties.
  • Next, set the value of “bluevoilet”, “10px” and “none” to the “color”, “padding” and “text-decoration” properties to enhance user visibility.
  • In the end, attach the “:hover” selector with the “<a>” tags and apply CSS properties to design it according to the website theme.

After the execution of the above code snippet, the output looks like this:

The output confirms that the navigation bar is now styled.

Step 3: Generate Hyperlinks to Additional Web Pages

To generate hyperlinks for additional web pages, insert the address of the pages relative to the HTML file as a value of the “src” attribute. Let us assume there are four pages “home.html”, “services.html”, “about.html”, and “contact.html” inside the HTML file folder:

<div class="navigate">

<div class="nav-menu">

<a href="home.html">Home</a>

</div>

<div class="nav-menu">

<a href="about.html">About</a>

</div>

<div class="nav-menu">

<a href="services.html">Services</a>

</div>

<div class="nav-menu">

<a href="contact.html">Contact</a>

</div>

</div>

In the above code snippet:

  • First, revisit the HTML file and place the additional file names as a value for the “href” attribute.
  • As in the above example, the folder is the same for all files, that’s why only names are provided as a value. If the files are placed in another folder, then the address must be placed as a value.

After the execution of the above code snippet, the output appears like this:

The above “gif” illustrates that hyperlinks are generated to additional web pages using the navigation menu.

Conclusion

To generate hyperlinks, the anchor “<a>” tags are utilized, and the address of HTML files is inserted as a value to the “href” attribute. It is essential to create an interactive browsing experience and optimize search engines. This article has demonstrated the steps for generating hyperlinks to additional web pages using HTML.

About the author

Abdul Moeed

I'm a versatile technical author who thrives on adaptive problem-solving. I have a talent for breaking down complex concepts into understandable terms and enjoy sharing my knowledge and experience with readers of all levels. I'm always eager to help others expand their understanding of technology.