Advantages of using a relative path for HTML link codes?

froggyboy604

Seasoned Veteran
Joined
Oct 22, 2007
Messages
3,165
Reaction score
1
FP$
5,109
a relative path looks like
Code:
<a href="/blog">blog</a>
while an absolute path looks like
Code:
<a href="http://example.com/blog">blog</a>
. I read online from members that using an absolute path might make indexing easier for some search engine bots vs using an absolute path.

While an relative link path is faster to type, and it is possible to move your HTML website to a new website domain name without rewriting the http://example.com part.

I also read for images it is better to use a relative path like
Code:
<img src="/pics/logo.jpeg">
instead of
Code:
<img src="http://example.com/pics/logo.jpeg">
which is a an absolute path.

Using absolute path for images, Flash, JavaScript and movie clips surely increases http request. So use relative path instead of absolute path to reduce the HTTP request.
http://www.bloggingjunkie.com/how-to-sp ... rt-ii.html

When is it appropriate to use a relative path and when is it better to use an absolute path on a HTML website?
 
Re: Advantages of using a relative path for HTML link codes

You should use;

Code:
http://www.example.com/folder/folder/index.html

For page links and pictures etc but in css never use the full link, use;

Code:
../images/icons/icon.png

It's up to you but never use anything other than the above in CSS or it will take longer to load the site and is pointless.
 
Re: Advantages of using a relative path for HTML link codes

Dan said:
Code:
../images/icons/icon.png

It's up to you but never use anything other than the above in CSS or it will take longer to load the site and is pointless.
I find ".." to be redundant.
 
Re: Advantages of using a relative path for HTML link codes

I always prefer to use a relative path for links and an absolute path for images :great:

I just find it much easier t use and that is the way I used html
 
Re: Advantages of using a relative path for HTML link codes

Santa said:
Dan said:
Code:
../images/icons/icon.png

It's up to you but never use anything other than the above in CSS or it will take longer to load the site and is pointless.
I find ".." to be redundant.

How is it redundant? In certain cases the CSS image path needs the ".." to pull the image.
 
Back
Top Bottom