0

I have a folder named "myWebsite". Inside that folder I have "index.html" and another folder named "other". Inside "other" I have CSS files JS files and "page2.html". I have linked all files with my "index.html". But when I am in "page2.html", I want a link that will lead me to "index.html".

<a href=".../index.html">go back</a>

3
  • From index you can use other/page2.html >> In page2 you will use ../ to step out of the other folder like that ../index.html Commented Jul 19, 2022 at 4:31
  • why are you putting your index.html inside a folder? usually you use a href="/" to go back to homepage or /index.html or whatever home page. unless you are still testing while its live you can do that im not sure where your myWebsite folder but this are ways its either ./index.html or what @MohamedEL-Gendy answer ../index.html or ../../index.html try this options. Commented Jul 19, 2022 at 4:42
  • Thanks guys. I understood now. I am new in this field so don't know much. I have Googled my question but couldn't find any solution. From there I found out that I can ask any coding related questions in stack overflow. Commented Jul 19, 2022 at 5:42

2 Answers 2

2

In order to navigate back you should use '../' if you want point two folders back you can use '../../' for instance.

In this case, within Page2.html use:

<a href="../index.html">go back<a>

NOTE: You have an extra dot.

Sign up to request clarification or add additional context in comments.

Comments

0

Based on what you wrote, this should fix it:

<a href="../index.html">link</a>

The ../ directory references the parent directory.

Examples:

<a href="sample.html"> The "sample.html" file is located in the same folder as the current page.

<a href="pages/sample.html"> The "sample.html" file is located in the pages folder in the current folder.

<a href="/pages/sample.html"> The "sample.html" file is located in the pages folder at the root of the current web.

<a href="../sample.html"> The "sample.html" file is located in the folder one level up from the current folder.

See here for more on HTML filepaths.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.