skip to Main Content

So I just started learning HTML and I wanted to start my first basic project. I am creating a website that allows the user to learn about the different coding languages. The home page is basic as of now, but it includes a link to learn more about HTML. However, that link does not work. I used <a href> and have it saved as a local file in the same folder as the home page, but on Chrome, it says, "Your file couldn’t be accessed". I included screenshots of the message, files, and the code itself.

Files

Home Page
Home Page code

HTML webpage
HTML code

I am wanting the HTML link to bring me to my second file of code that explains what HTML is.

codes for link to HTML page:

<a href="/html.html>HTML</a>

Code for gong back to coding page:

<a href="/coding.html>BACK</a>

5

Answers


  1. Try to remove ‘/’ in href
    if both html files are in the same folder

    Login or Signup to reply.
  2. You need to remove the / before the file name.

    <a href="coding.html">
    
    Login or Signup to reply.
  3. You tried to remove the bar, the bar took you to the root, that is, to c:

    Login or Signup to reply.
  4. using only / is pointing to the absolute root directory where in your case it is C: drive in your computer regardless of the directory you used (desktop or any other directory in C drive).

    You need to use ./ to point to the base url where by default it is the current directory if you have not defined base url in the header.

    Or you may omit / and set only html.html or coding.html as href value if you didn’t set base url in your document and all files are in a same directory

    Login or Signup to reply.
  5. the problem in your code is that your setting your href path to "/code.html", this will send you to the root of wherever you’re loading your file (In this case, the root of your C: disk).

    What you want in this case is to use relative paths, which take as a starting point, the root of your project (HTML Project 1).

    You can use as some other comments says just "code.html" and it will infeer the relative path but it would be better to use "./" as it is what indicates the path is actually relative at the begining, specially if you’ll work in the future with more folders for your routing.

    so for your code, you’ll have "./code.html"

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search