How to link one html page to another one in another folder

江枫思渺然 提交于 2019-12-01 14:46:30

To link to another file WITHIN your web site structure, you should use relative references. Relative means, relative to the currently loaded resource.

To access something in the same folder: Just use the file name:

<a href="file.html">Click Me<a>

To access something in a child folder: Start with the child folder name, a slash, and the file name:

<a href="childFolder/file.html">Click Me<a>

To access something starting at the root of your site, begin the path with a forward-slash:

<a href="/pathToFile">Click Me<a>

To access something in a parent folder, start with two dots and a forward-slash:

<a href="../file.html">Click Me<a>

To access something that is in a combination of the above, like a sibling folder, you need to go up to the parent and then down to the correct child:

<a href="../digital-clock/index2.html">Click Me<a>

As an initial test to make sure the file exists, temporarially place it in the same folder as the current page and see if the first example I showed works. If not, you've got a different issue than you think.

Next, you mention that index2.html is in the digital-clock folder, but you didn't reference that folder in your link, so make sure to include that. But, depending on where that folder is will dictate which method I've shown above you need to use.

This should work <a href="../rock-paper-scissors-game2/index2.html">Game</a>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!