QA.TechInterviews.com - your tech questions answered
HTML Link Problem?
hi all,
I hav two html pages. say sports.html and other in cricket/cricket.html. In sports.html, i will giv the link to cricket.html as <a href="cricket/cricket.html">click to go to cricket page</a>. Now what should i giv in cricket.html to go back to sports page ?? Note: cricket.html is in cricket directory and sports.html is in the root directory.

thanks
../sports.html

the ".." means "up one directory level".
Or you can use /sports.html, and then it will look for your main page in the root directory.

I advise on the 1st one, because you might want to put everything in another directory, and you'll lose the paths if you use the 2nd method... Always use relative paths (1st method) other absolute paths (2nd method) when possible.

the entire link would then be <a href= "../sports.html"> link to main sports page </a>
../sports.html

the ".." means "up one directory level".
Or you can use /sports.html, and then it will look for your main page in the root directory.

I advise on the 1st one, because you might want to put everything in another directory, and you'll lose the paths if you use the 2nd method... Always use relative paths (1st method) other absolute paths (2nd method) when possible.

the entire link would then be <a href= "../sports.html"> link to main sports page </a>
If your directory system looks something like this:

\ --+--sports.html
+--cricket----cricket.html


write on "sports.html": <a href="cricket/cricket.html>---</a>
and on "cricket.html": <a href="../sports.html>...</a>
../sport.html

Back to QA. TechInterviews.com. Powered by Yahoo! Answers and TechInterviews.com community.