In our last episode,
<11*********************@s13g2000cwa.googlegroups. com>,
the lovely and talented
li*****@gmail.com
broadcast on comp.infosystems.
www.authoring.html:
How can i cobine my image with a html file so i only have one file. The
image is used inside the html file so if i delete it or move it, then
it wont show up in the html file. :)
Basically, you can't. HTML is a form of text. Most image formats are
binaries (there are a few that are encoded in text, but there is no
way to tell a browser "take the following text as a <someformat>
image."
You can make the src link in the IMG element relative, so if you move
both files, maintaining the same relation between them, the image will
still show up. On the other hand, if you give the src as a complete
url, the image will show up wherever you move the html.
for example
1)
<img src="myimage.gif" ....will allow the browser to find the image if it
is the same directory as the html file, and this will work not matter where
that directory is. If you browser can find the html, it can find the image
in the same directory, permissions permitting. (There are a few execeptions
and qualifications here, none of which I think you are ready to hear.)
on the other hand:
2)
<img src="http://yourdomain.com/images/yourimage.gif" ...>
will find yourimage.gif if it is in whatever directory
http://yourdomain.com/images/ points to. Wherever you move the html,
if the browser will try to look for the image in that place. The problem
with this if you ever move the image, the src has to be changed everyplace
you have entered the complete uri.
In other words, 1) will work if you move both the html and the image
together, and you don't have to change anything in the url.
2) will work wherever you move the html, but will stop working if you
ever move the image.
In most cases 1) is the best choice. If you use only relative links,
you can move a whole site without having to change any html.
--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
War on Terrorism: Bad News from the Sanity Front
"There's one thing ... that I do like about Rumsfeld, he's just a little bit
crazy, OK"? --Thomas Friedman, _The New York Times_