Question:
XHTML help? Image won't display...?
Liszt
2008-09-16 14:56:15 UTC
I am having difficulty with an assignment for my Computer Applications class. Can anyone help me?

We have to create webpages that we can view using the "File > Open" thing--you know, the kind that's only accessible on the computer it was created on. Anywho, I've just added this tag:



And all I get is a box with the red X--the image not found kinda thing. I'm not new to XHTML; I've checked for coding errors, checked that the filename is right, made SURE I've got the image saved in the same folder as my page...but, nothing. What am I overlooking?

Any amount of help would be nice. ^_^
Six answers:
Some Guy
2008-09-16 17:30:52 UTC
What it amounts to is that the image file needs to be *found* by the web page, either by means of a direct and complete (and *regular* path), or by means of a so-called "relative" path.



Let's say that your web page is placed inside



C:\Documents and Settings\you\My Documents\ Web\ page.html



If the image is in the same folder, e.g.:



C:\Documents and Settings\you\My Documents\ Web\ test.jpg



then all you need *is*







If the image is placed in a subfolder, like



C:\Documents and Settings\ you\ My Documents\ Web\ images\ test.jpg



then all you need is







However, if the image is placed someplace else, like



E:\ Pictures\ test.jpg



then what you need to do is







This ONLY works if you open the web page as a file on your own computer, browsing for an HTML file using the File | Open menu.



And before people start yelling "that doesn't work!"... I just created a web page on my own system, did exactly this, and it works.



When opening a web page on an actual web server, the image MUST be inside the actual web root (regardless of the subfolder it's in).



So if the web root is, for example, E:\ web\ www\, then the image must be placed in that folder or one of its subfolders. A web page called on a web server has no access to files outside the defined web *site* - but again, if you simply open an HTML file with a double-click (or browse to it using File | Open), this restriction does not apply.



Also keep in mind that the HTML file and the image must be located on one computer (which includes locations on network shares.)
TC
2008-09-16 15:12:21 UTC
This is what you need: Test



This tells it to display the image and and if th image can not be found to display the word "Test". The file:/// will let you display the image properly. Make sure the image is in the same folder as your XHTML document. If this doesn't work, still use the file:///, but add the exact file name in place of test.jpg, like this:



Test
vargonian
2008-09-16 15:01:22 UTC
Okay, first check to make sure that the file test.jpg is in the exact same folder as the .xhtml (or html) file. Is it?



The syntax looks correct, and proper XHTML unless I'm mistaken.



Edit: Aw, my mistake about the same folder issue. This is a little puzzling; could you post the entire html, or at least a basic skeleton that reproduces the issue? You can use a site like http://www.rafb.net/paste/ to make it easier.
anonymous
2008-09-16 15:28:24 UTC
Use the full path:





/ is the root of the drive the html file is in.



Firefox works with just the filename, but some browsers might not.
nutter
2016-10-03 12:04:14 UTC
After examining this chick's profile, i might incredibly think of that is risk-free to assert she is largely a individual very knowledgeable in Adobe photoshop cs2 & html scripting in Notepad. In different words, she made it herself, and there is not any thank you to truly get into her profile and consider that is shape of codes. it is not basically a premade format you could thieve, yet to set those varieties of bins up and stuff, all you may desire to do is study a thank you to script in html for your self. while you're no longer keen to try this, then i dunno what to tell you cuz this profile would be perplexing to reproduction.
Richard
2015-03-04 23:44:01 UTC
eyyst6ytwetyya


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...