Making multiple pages
1. Websites usually have more than one page
Most websites are made from multiple pages that work together to share information
A multi-page site usually repeats the same layout on every page so it feels consistent
- Open a familiar website in a browser.
- Click two different navigation links at the top of the page.
- Notice that the URL changes, but the site layout stays similar.
2. A new page is usually a new .html file
In a basic website, each page is typically a separate file ending in .html
If you only create index.html, then you only have one page available to navigate to
- Open your website project folder in Visual Studio Code.
- Confirm you already have a file named
index.html. - Create a new file named
tokyo.htmlin the same folder.
3. File naming matters because links must match exactly
When you link to another page, the link must use the exact file name, including spelling and capitalizationTokyo.html is different from a link to tokyo.html
Good file names are short, lowercase, and avoid spaces, because they are easier to type and less error-prone
- Create three more empty files:
osaka.html,hiroshima.html, andmatsuyama.html. - Check that all five files are in the same folder:
index.htmlplus the four city pages. - Check that every file name is lowercase and has no spaces.
4. Hyperlinks connect pages using the <a> element
A hyperlink is created using an anchor element written as <a>, which tells the browser that text should be clickablehref attribute, which is the address the browser loads when clicked
When you link between pages in the same folder, the href can be just the file name like tokyo.html
- Open
index.htmlin VS Code. - Add a link that points to
tokyo.htmlusing an<a>element. - Save the file and click the link in the browser to confirm it loads.
<p>
<a href="tokyo.html">Tokyo</a>
</p>
5. Each page should identify itself so you can tell where you are
When you create multiple pages, each page needs a clear heading so the user knows which page they are viewing
A simple way to do this is to put a city name heading near the top of each page using <h1>
- Open
tokyo.htmland add an<h1>heading that saysTokyo. - Add a short paragraph describing what the page will be about.
- Repeat for
osaka.html,hiroshima.html, andmatsuyama.htmlusing the correct city name.
<h1>Tokyo</h1>
<p>This page will include facts, images, and links about Tokyo.</p>
6. Navigation works best when every page links to every other page
If only the home page contains links, users cannot move easily between pages without going back first
Consistent navigation is important because users build habits based on where links appear
- Create a navigation area near the top of
index.htmlusing a<nav>element. - Inside it, add links to
index.html,tokyo.html,osaka.html,hiroshima.html, andmatsuyama.html. - Copy the same
<nav>block into the top of all four city pages.
<nav>
<a href="index.html">Home</a>
<a href="tokyo.html">Tokyo</a>
<a href="osaka.html">Osaka</a>
<a href="hiroshima.html">Hiroshima</a>
<a href="matsuyama.html">Matsuyama</a>
</nav>
7. A <nav> element is a semantic label for navigation links
The <nav> tag tells the browser and other tools that the links inside are for site navigation<nav> to help users move around the page efficiently
Using semantic tags also makes your code easier to understand because it communicates intent
- Check that your navigation is inside
<nav>on every page. - Confirm that each page includes the same five links in the same order.
- Click through every link to confirm none of them are broken.
8. CSS can style the navigation so it looks like a bar, not plain links
By default, navigation links appear as standard blue underlined text, which is usable but looks unfinished
A common approach is to give the <nav> a background and padding, then style the links for consistent spacing
- Create a folder named
cssif you do not already have one. - Create a file named
style.cssinside thecssfolder. - Copy the CSS example into
css/style.cssand save the file.
nav {
padding: 12px;
background: #f0f0f0;
}
nav a {
margin-right: 12px;
text-decoration: none;
}
9. Your pages must link the CSS file or the styling will not apply
CSS does nothing until the HTML page loads it using a <link> element in the <head>
The href for the stylesheet is also a relative path, so it must match the folder structure exactly
- In every page file, add a
<link>tocss/style.cssinside the<head>. - Save all files and refresh each page in the browser.
- Confirm the navigation bar styling appears on every page.
<head>
<title>Tokyo</title>
<link rel="stylesheet" href="css/style.css">
</head>
10. Improve the navigation styling so it is clearer and easier to use
Good navigation styling makes links easy to see and easy to click, which reduces user mistakes
Small CSS changes like bold text, stronger contrast, and a hover effect can make the interface feel deliberate
- Add the improved CSS rules to
css/style.css. - Refresh the page and hover your mouse over each navigation link.
- Check that the hover effect makes it obvious which link you are pointing at.
nav {
padding: 12px;
background: #f0f0f0;
border-bottom: 1px solid #cccccc;
}
nav a {
margin-right: 12px;
text-decoration: none;
font-weight: 600;
color: #222222;
}
nav a:hover {
text-decoration: underline;
}