homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

What's the proper way to link to files? Need some help.
Linking correctly to files? Seen different types of links.Please help:)

 7:22 am on Jul 23, 2005 (gmt 0)

Hi guys:)

I was wondering, what's the proper way to link to files?
>>**Only to files that i created for *my* site.<<

**Not to other websites.
**Other websites i know i need to us the http:// or www. for these outside links.

I ask because i've seen some websites use the link like this:


<a href="file.html">File</a>

and others use this code:


<a href="http://www.blahwidget.com/file.html">File</a>

and others use this code:


<a href="www.blahwidget.com/file.html">File</a>

Well, please explain as i don't want to link the wrong way and not have it work. A little concerned.

Q.1. Which way should i link? Can i just use the first example for all links on my site? I'd like to use this for all my links.

>> <a href="file.html">File</a>

Well...Thanks for your help guys:)




 9:21 am on Jul 23, 2005 (gmt 0)

Basic simple relative linking is best.

Some people think otherwise but I doubt many of them have done any programming. Search engines will treat all links identically. Why is that I hear you ask? Simply because all link information will be stored in a single normalised format. Whether the links appear on a page in relative or absolute form will make no difference.

So, to ensure easy maintenance (static html) and reduce page size, use relative urls. However, for dynamic pages, the issue of easy maintenance is blurred.

HOWEVER, www.domain.com may be treated as a separate url to domain.com


JAB Creations

 9:21 am on Jul 23, 2005 (gmt 0)

I'll keep it simple...

There are two TYPES of links, absolute and relative.

All absolute links start with "http://"
"http://www.webmasterworld.com" is an absolute link.

Relative links start with either...

The file itself...
... or ../ to go UP a directory to access a file.

If we're at http://www.example.com/1/2/3 and we want to link to...
http://www.example.com/1/bob.html we'd use...

<A href="../../bob.html" .....


There are good and bad reasons to use both, you'll find out what your preference is sooner or later though.

Also you ~MUST~ use [....] This tells your computer to look on the internet. This would be the same thing if you asked me where the (closest) penguins are and I pointed north; assumming we're in like the US/Europe/etc and not in like umm, with our good mates in Aussie!

It's a love/hate feeling when I see people not use the http:// protocol in hyperlinks.

If you're on the page...

and you make a link of...

Your link will bring you to...

Hope this helps!


 9:38 am on Jul 23, 2005 (gmt 0)

the first option is correct. Because we give virtual path.


 11:52 am on Jul 23, 2005 (gmt 0)

Thanks guys for your help:)

Ok. So if i use absolute linking it would be placed like this for all files i link to.

>> <a href="http://www.widget.com/index.html">Home</a>

Q.1. >>Can i use this for all my links on my site?

Q.2. I don't know anything about directories so if my files are all in the same folder or area will it be ok to use the link:

<a href="http://www.widget.com/index.html">Home</a>

for a link to a file in the same folder such as a file
named index.html

Q.3. Would'nt i link to this with just the
<a href="index.html">link</a> since the file is in the same folder?

Q.4. What is wrong with useing the
<a href="widget.html">Link</a>

Q.5. Also if my files are all named like this:




>>Q. When i upload them to my web space, will the domain that is set-up automatically attach the index.html file to the domain?

Like this:

or do i have to do this somehow?

Q.6. >>>Also, will my host automatically set-up the domain as [-----.com...]

**(deleted name so it won't link.)

I ask because if i get inbound links i would like to receive the credit for the links with http:// or the www. (depending on how you have your link set-up.)

I've read that you only receive credit for one or the other.

Not sure how this all works.

**Please answer all questions:)
I really need some help as i'm new to placeing a site online.

ps. Is it ok if i sticky mail you if i need assistance with set-up of my website?

Thanks again guys:) Your very helpful:)



 12:27 pm on Jul 23, 2005 (gmt 0)

Even though relative links are easily implemented, one of the ways to combat "302 hijacking" is to use absolute links even for internal pages of your website.

If prefer to use relative URLS make sure you have <base href="http://www.example.com/"> were its your domain of course, in the header of of each document.


 4:49 pm on Jul 23, 2005 (gmt 0)

If prefer to use relative URLS make sure you have <base href="http://www.example.com/"> were its your domain of course, in the header of of each document.

Can you expand on that thought?


 2:15 am on Jul 24, 2005 (gmt 0)

Hey outrun:)_

Q.1. What's 302 hijacking? I'm not an expert like you guys:) I would like to just like to link up my pages safely so they work properly?

Q.2. Can i just use:
<a href="http://www.---.com/index.html">link</a>

for all my links and be protected?

Thanks guys for your help:)

Also, can you guys refer to my above questions and answer them as well? I really need your guys advice. I'm a newbie and i don't know as much as you guys yet.

Thanks guys:)



 7:29 am on Jul 24, 2005 (gmt 0)

I don't like relative links like ../../../folder/filename.html

I prefer to always "count from the root" like: /folder/folder/filename.html instead.


When linking to an index file, do not include the index file filename in the link, end the link with trailing / only. Link to http://www.domain.com/ or / or /folder/ or http://www.domain.com/folder/ instead.


 8:09 am on Jul 24, 2005 (gmt 0)

Unfortunately, this thread is trying to cover too many topics and that will make it pretty hard for future visitors to make use of. We prefer to have one question or topic per thread - that structure helps us to build a knowledge base that helps many people in the future, not just those who are in the thread today. So I'm going to enforce that idea by locking this thread now.

A number of your questions, frenzy77, can be found by using Google to search our site. For instance, enter site:webmasterworld.com 302 hijack and you will find MANY discussions about a pretty bewildering and frustrating topic. However, if you are just starting to learn HTML, it's probably just going to confuse things for you.

So I'd suggest you continue to ask questions about things you can't find answers for with a reasonable amount of searching - but one topic per thread, please. And don't forget that we have a forum dedicated to people who are New To Web Development [webmasterworld.com] -- you may find lots of answers in there.

In particular, as with every forum here, there is a Library linked at the top of every page in the New to the Web forum that holds some of the very best posts. There is one thread in particular that lists links to many other educational threads:

Valuable Reading for the New Webmaster [webmasterworld.com]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved