Search code examples
htmlhref

Anchors to pages not working?


Im trying to learn html and i ran into trouble,

This is the homepage:

<head>
    <title>title</title>
</head>

<body>
    <h1>Welcome to ....</h1>

    <ul>
        <li>Home</li>
        <li><a href="page2.html">Page 2</a></li>
        <li><a href="page3.html">Page 3</a></li>
    </ul>

    <h2>Homepage</h2>
    <p>Homepage content...</p>

</body>

The second page:

<head>
    <title>Page 2</title>
</head>

<body>
    <h1>Welcome to ...</h1>

    <ul>
        <li><a href="index.html">Home</a></li>
        <li>Page 2</li>
        <li><a href="page3.html">Page 3</a></li>
    </ul>

    <h2>Page 2</h2>
    <p>Page 2 content...</p>

</body>

The Third page:

<head>
    <title>Page 3</title>
</head>

<body>
    <h1>Welcome to ...</h1>

    <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="page2.html">Page 2</a></li>
        <li>Page 3</li>
    </ul>

    <h2>Page 3</h2>
    <p>Page 3 content...</p>

</body>

I saved them in one folder on my desktop but for some reason whenever I click the 2nd or 3rd page links in chrome it just tells me that the webpage is not found. Please help.


Solution

  • Thanks for the help everyone,

    I had spaces in the file names, it got fixed when i removed them. The names must be exactly the same as the .html href links in the files.