when building a website i can't link to images using an src attribute

Asked by Jonathan Todd

I can't link images to a website using src. I don't know if anything is wrong with my computer. When I got it refurbished from Free Geek and turned it on for the first time, a flasher came on telling me that I have an internal language problem, but folks seemed to think it was no big deal. I had problems linking a CSS file to an HTML file earlier. Manfred Hampl rescued me by providing me with a foolproof tutorial. He said that if I couldn't to it according to these instructions then something was wrong with my browser. I tried the tutorial and it worked (thanks. Manfred!). I found out later that the first tutorial was flawed.I seem to remember, though my memory may be flawed, that I couldn't link an image using Manfred's tutorial and then later, when using another tutorial from the same people (W3C) I couldn't link images. This happened twice. Could Manfred or someone else send me a tutorial that would test whether I'm doing it wrong, or it's my browser(or some other part of my computer)?

                                                                                                                                            Thanks,
                                                                                                                                               J.T.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

Just use you favorite web search page to find several million hits for "html tutorial", or "learning html" or similar.
Or visit your nearest public library or bookstore to find guides on paper how to create html pages.

As far as I can remember, the cause for CSS not working on your first attempt was extra quotes, so maybe also in the case for images not working it is a similar trivial error.

Revision history for this message
Jonathan Todd (stenchwrench-p) said :
#2

Dear Manfred:
                            Here's the code that failed:
<!DOCTYPE html>
<html>
<body>

<h2>Norwegian Mountain Trip</h2>
<img border="0" src="/images/pulpit.jpg" alt="Pulpit rock" width="304" height="228">

</body>
</html>

In this case, only the words Norwegian Mountain Trip came up and not the photo (this was from a W3C tutorial)

Revision history for this message
Best Manfred Hampl (m-hampl) said :
#3

I assume you are referring to http://www.w3schools.com/html/tryit.asp?filename=tryhtml_pulpitimage
If you check that site, you can find out that on that site the html source is in a /html directory, and the images are in an /image directory. Only if you have duplicated such setup on your system, then the link "/images/pulpit.jpg" is correct. If you have a different setup of the files and directories on your system, you have to adapt the addresses to match your setup.

The address src="/images/pulpit.jpg" refers to an image named pulpit.jpg in the top directory /images which most probably does not exist on your system.
If you have a subdirectory named "images" below the html source directory, then the link address has to be
src="images/pulpit.jpg"
without slash at the beginning.
If you have the images stored in the same directory as the html source, it has to be
src="pulpit.jpg"
If you try using the image file from the W3C pages without storing locally, it has to be
src="http://www.w3schools.com/images/pulpit.jpg"

Revision history for this message
Jonathan Todd (stenchwrench-p) said :
#4

Thanks Manfred Hampl, that solved my question.