everyone. I am currently working on the CS50 pset5 homepage problem. I have encountered a problem in my code. The code needs to contain at least four different .html pages, and it should be possible to get from any page on your website to any other page by following one or more hyperlinks. I have created four .html pages, and am able to use the link to go to other pages, but only for once.

Suppose I first clicked into page a.html, then the css and the link works fine. Then if I use the link on page a to get to other html pages, then the css code will fail, then if I try to go to another page from the second page, then it will fail, and the CSS code would fail again.

This is the code of html page B. Any advice would be helpful! Thanks!

<!DOCTYPE html>

<html lang="en">
        <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
        <link href="styles.css" rel="stylesheet">
        <title>My Webpage</title>
        This is Page B!
        Visit <a href="Hello World.html/">Hello World</a>.
        Visit <a href="a.html/">a</a>.
        Visit <a href="index.html/">index</a>.

1 Answer 1


The problem is because of the trailing slash (/) in the href attributes, for example href="a.html/". There are two places you can see feedback that will describe what it is doing. One is the address bar in the browser, notice on the second click it will look something like http://ec2-......amazonaws.com:8080/b.html/a.html/. You can also look at the server log (that is in the console where you ran http-server). It will show something like "GET /b.html/a.html/" Error (404): "Not found".

Remove the trailing slash, and you will make progress.

By using the trailing slash in the address, you are essentially telling the browser that "b.html" is a directory, and in Unix parlance, it becomes the working directory for subsequent (relative path) links. (A full-path link with have the full URL starting with "http[s]://").

Another change that would work: move the trailing slash to the front of the link. That would tell the browser to look in the document root for the page.

  • I GET IT!!! Thank you!
    – jsyf
    Commented May 13, 2019 at 21:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .