
Every website, no matter how large or small, is built on a simple idea: pages connected to other pages. The ability to link one web page to another is what turns a collection of separate documents into a usable website. If you are just starting with HTML, learning how to link two pages together is one of the first and most important skills you will master. In this tutorial, you will create two HTML files, connect them with links, understand the difference between relative and absolute paths, and learn best practices that keep your links reliable, accessible, and search-engine friendly.
Why Businesses Hire AAMAX.CO for Professional Web Development
While linking two pages is a great learning exercise, a professional business website requires careful planning of structure, navigation, and internal linking. That is where AAMAX.CO comes in. They are a full service digital marketing company offering web development, digital marketing, and SEO services worldwide. Their team handles everything from clean, standards-based HTML to scalable website development, ensuring every page links logically and supports both users and search engines. If you would rather focus on running your business, they can build a fully connected website for you.
Understanding the Anchor Tag
In HTML, links are created with the anchor element, written as <a>. The most important attribute of this element is href, short for hypertext reference. The value of href tells the browser where the link should go.
<a href="about.html">About Us</a>The text between the opening and closing tags is the clickable link text that visitors see. In this example, clicking "About Us" opens the file called about.html.
Step 1: Create Two HTML Files
Start by creating a folder for your project. Inside it, create two files: index.html and about.html. You can use any text editor, such as Visual Studio Code, Sublime Text, or even Notepad. Here is a simple structure for the first page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Home</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This is the home page.</p>
</body>
</html>Create the about page using the same structure, but change the title and heading to "About."
Step 2: Add a Link From the First Page to the Second
Inside the body of index.html, add an anchor tag that points to the about page.
<p>Learn more on our <a href="about.html">About page</a>.</p>Save the file and open it in a browser. When you click the link, the browser loads about.html. Because both files are in the same folder, you only need the file name.
Step 3: Link Back to the First Page
Navigation works best in both directions. Open about.html and add a link back to the home page.
<p><a href="index.html">Back to Home</a></p>Now your two pages are fully connected. Visitors can move freely between them, which is the foundation of website navigation.
Relative Paths vs. Absolute Paths
The links above use relative paths, meaning the location is relative to the current file. Relative paths are ideal for linking pages within your own website because they continue to work even if you move the whole site to a new domain.
about.htmllinks to a file in the same folder.pages/about.htmllinks to a file inside a subfolder called pages.../index.htmlmoves up one folder level before finding the file./contact.htmlstarts at the root of the website.
Absolute paths include the full URL, such as https://example.com/about.html. Use absolute paths when linking to external websites or when you need a link that works from anywhere, such as in emails.
Opening Links in a New Tab
Sometimes you want a link to open in a new browser tab, which is common for external resources. Add the target="_blank" attribute along with rel="noopener noreferrer" for security.
<a href="https://example.com" target="_blank" rel="noopener noreferrer">Visit Example</a>For internal links between your own pages, it is usually better to open them in the same tab so visitors are not overwhelmed by multiple windows.
Creating a Simple Navigation Menu
As your site grows beyond two pages, a navigation menu keeps links consistent. Place the same menu at the top of each page.
<nav>
<a href="index.html">Home</a>
<a href="about.html">About</a>
</nav>Using the semantic nav element tells browsers and assistive technologies that this group of links is the main navigation.
Styling Your Links With CSS
Browsers display links in blue with an underline by default. You can customize their appearance with CSS while keeping them recognizable.
a {
color: darkred;
text-decoration: underline;
}
a:hover,
a:focus {
color: black;
}Always style the focus state as well as the hover state, so keyboard users can see which link is selected.
Best Practices for Linking Pages
- Use descriptive link text. Phrases like "View our services" are clearer than "click here" and help SEO.
- Keep file names simple. Use lowercase letters and hyphens, and avoid spaces.
- Test every link. Broken links frustrate visitors and can harm search rankings.
- Be consistent. Keep navigation in the same place on every page.
- Think about structure. Plan how pages relate to each other before you start linking.
Troubleshooting Broken Links
If a link does not work, check the file name for typos, confirm the file extension is correct, and make sure the path matches the folder structure. Remember that file names on many web servers are case-sensitive, so About.html and about.html are treated as different files. Browser developer tools can also show a 404 error in the network panel, confirming the file could not be found.
Conclusion
Linking two web pages in HTML requires just one element: the anchor tag. By creating your files, adding href attributes with the correct paths, and linking pages in both directions, you build the core structure of a website. Add a navigation menu, use descriptive link text, and test your links regularly, and you will have a solid foundation for growing your site into something much bigger.