Hi, I have a question.I have a folder called Web Site.Inside it I have 2 folders n.1 and n.2.Inside folder1 I have a page called index.htm.Inside folder2 I have a page called home.htm.How do I link index.htm with home.htm and viceversa? I appreciate your help thank you.

Recommended Answers

All 6 Replies

If you are using relative links, use .. to indicate the level above.
So to link from index.htm to home.htm:

<a href="../folder2/home.htm">link to home</a>

To link from home to index, do the same but replace folder2 with folder 1, and home.htm with index.htm.

Hmm on a second read-through, I see you said link with, not to. If my previous post does not address your question correctly, please clarify what you mean.

Dear 'Fiorentino01^', there are 2 ways to do this:

  • Write the full path
    Ex: <a href="http://www.domain.com/web-site/2/home.html">go to Home</a> (This will be placed in the page index.html) and same thing with home.html

  • Write the path starting from the location of the file you are coding
    Ex: you are coding the page index.html, just write <a href="../2/home.html">go to Home</a>

../ is to go to the upper folder (Parent directory)

Here's a good tutorial for HTML paths
http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/

Good Luck

Write the full path

This is called absolute path. This style is not recommended when you works on a website. It is easy on web developers but it is not really portable and not easy to maintain. Also, it could come and bite you when there are some changes in the future.

Write the path starting from the location of the file you are coding

This is called relative path which is supposed to be done in web developing. The .. means to go up one level from the directory/folder where the current being displayed location is. For example, the current location of the displayed HTML file is http://www.xxx.yyy/path/to/page1.html and you define a link inside the page1.html as ../mypage.html. As a result, the path resulted from it becomes http://www.xxx.yyy/path/mypage.html because the .. move the location from http://www.xxx.yyy/path/to/ to http://www.xxx.yyy/path/.

Thanks to all of you Problem SOLVED!!

Problem solved thank all who contributted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.