You are here: Re: HTML HREFS - confused... « HTML « IT news, forums, messages
Re: HTML HREFS - confused...

Posted by frederick on 04/24/06 00:41

Domestos wrote:
> I've read till I am blue in the face examples and thoughts on proper use of
> the HREF tag.

There's no such thing as an HREF tag! You probably mean the "href" and
"src" attributes of elements such as <A> and <IMG>.

> I develop and test locally and post the development to a website like most
> of us...
> my local development 'index.html' exists at...
> http://localhost/dev/mywebsite/index.html
> however,
>
> My webpage exists at
> http://www.mywebsite.com/index.html
>
> How do i use HREF for local links i.e. graphics in the root/GFX folder
> etc..so they work on both my development area and my website without
> changing them everytime I upload them online. I'm really confused.... does
> BASE HREF have a part to play?

Your local directory structure should mirror that of your web server;
you could also make use of <BASE href="[whatever]">, but it's not
normally necessary.

If you wanted to use a local directory "P:\Web design" for your work,
for example, then that would be equivalent to the root directory of
your site up at "http://www.example.com". So your index page would be
"P:\Web design\index.html" locally, and
"http://www.example.com/index.html" remotely.

To get images and so on to work correctly, use relative URLs. Thus if
you have an image file locally at "P:\Web design\images\foo.jpg", then
when editing index.html you'll use HTML that's something like this:
<IMG src="images/foo.jpg" height="74" width="83" alt="whatever"
title="fred">
When you upload your image you'll then make sure that it goes into a
directory named "images" on your web server.

If the HTML file isn't in your project's root directory, then you'll
need to prefix the image's URL with "../" for every directory you're
down the ladder. For example, to insert an image stored locally at
"P:\Web design\resources\images\bar.jpg" into an HTML file stored
locally at "P:\Web design\marketing\sales\new\2006.html", then you'll
use code something like this:
<IMG src="../../../images/foo.jpg" height="74" width="83"
alt="whatever" title="fred">

By doing it this way, your pages will display as intended both locally
and remotely. You'll have to keep count of how many folders you're
going up or down the ladder, although if you're using a decent HTML
editor it should handle this for you.


BTW, I've used Microsoft Windows paths above for the local paths, but
it should be obvious enough how to convert them to something meaningful
if you're using a Linux-based system or whatever else.

--
AGw.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация