Click to See Complete Forum and Search --> : IMG problem. But why?
dj_jay_smith
09-16-2009, 02:38 AM
Hi Guys,
So I don't know HTML that well, but I thought I knew the basics until I started having this problem.
I have some very basic HTML code to just show an image from my site. But for some reason it does not work and I can not see what I have done wrong. It must be something simple, but I just can't see it and I have tried many things.
My code;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<Title>Test</title>
</HEAD>
<Body>
<IMG SRC="http://www.example.com/images/myimage.gif" ALT="ama" /> <br>
<IMG SRC="http://newsimg.bbc.co.uk/media/images/46136000/gif/_46136662_gazabomb226index.gif" ALT="test" />
</BODY>
</HTML>
The first IMG tag does not work. But if I copy and paste the link into my browser then the image displays fine, no problem. So it can't be a permissions problem (can it?).
The second IMG tag is basically just a test to show an image from another site and this work perfectly, no problem and I can't see any difference with it compared to the first.
I have tried all variations on the SRC link, and I have moved my image from /images into the root but all with no luck.
Any ideas, as it must be simple but it is driving me crazy!
Thanks for your help.
Jason
cfajohnson
09-16-2009, 08:13 AM
Hi Guys,
So I don't know HTML that well, but I thought I knew the basics until I started having this problem.
I have some very basic HTML code to just show an image from my site. But for some reason it does not work and I can not see what I have done wrong. It must be something simple, but I just can't see it and I have tried many things.
My code;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Why Transitional? What are you transitioning from? If it's a new page use HTML 4.01 Strict.
<HTML>
<HEAD>
<Title>Test</title>
</HEAD>
<Body>
<IMG SRC="http://www.example.com/images/myimage.gif" ALT="ama" /> <br>
<IMG SRC="http://newsimg.bbc.co.uk/media/images/46136000/gif/_46136662_gazabomb226index.gif" ALT="test" />
</BODY>
</HTML>
The first IMG tag does not work.
Of course not; the image file doesn't exist on that server, which is used only for examples.
Either post the real URL, or (better) post the URL of the page that has the problem.
WebJoel
09-16-2009, 08:28 AM
"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
is actually meaningless without the also-require URI address that 'supplies' the rules for it:
example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
(worth noting, in XHTML strict, the "html" needs to be lowercase as I have here)
:-)
dj_jay_smith
09-16-2009, 09:49 AM
Hi,
The doctype came from a template for the editor I was using, so that is why it is probably out of date/wrong.
But now I have changed but I still have problems. So here is my code again now (with the correct link).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<p>
<IMG SRC="http://www.wishindex.com/images/amazonbuy.gif" ALT="ama" /> <br>
<IMG SRC="http://newsimg.bbc.co.uk/media/images/46136000/gif/_46136662_gazabomb226index.gif" ALT="beatles" />
<br> <br>
</BODY>
</HTML>
I also tried the doctype <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
But it did not make any difference
cfajohnson
09-16-2009, 10:03 AM
Your page is not written in XHTML. In XHTML, all tag names are lowercase.
Use the HTML 4.01 strict datatype as there is no point to using XHTML (IE doesn't understand XHTML and parses it as it would HTML). Change "/>" to ">", and you have good HTML.
As there's nothing obviously wrong with your HTML, the only way you are going to get help is if you post the URL to the page that has the problem.
Coyotelab
09-16-2009, 12:02 PM
is this a yahoo store template?
Give the image width="" and Height=""
dj_jay_smith
09-17-2009, 01:53 AM
Hi,
Well I tried that and still have problems. My URL is http://www.wishindex.com/test.html
Jason
cfajohnson
09-17-2009, 04:20 AM
Strange.
It works when I copy the file to
ttp://cfaj.freeshell.org/testing/ama.html, but not on your site...
...but now I do see it on your site!
My first thought was that the browser was interpreting the empty width and height settings as 0, but why would it not be consistent from one location to another?
dj_jay_smith
09-17-2009, 05:18 AM
Well I also tried without the height and width properties, and setting them to values. But the net result is the same.
Could it be a permissions problem?
Charles
09-17-2009, 05:57 AM
Could it be a permissions problem?I'm thinking that it's something like that. It's almost as if you are set up to deny hot linking, only you're set up backwards.
dj_jay_smith
09-17-2009, 06:02 AM
Well I set the rights for the directory and file to 777 but it doesn't help!
kiwibrit
09-17-2009, 02:08 PM
Just looked at the page. I can see an amazon icon and a picture of a burning building beneath that.
Can we take it this problem has been resolved?
dj_jay_smith
09-18-2009, 02:22 AM
Yes, I managed to resolve the issue late last night.
I contacted my hosting provider and they suggested that I looked at 'hotlink' protection on my account. Once I had disabled this then it worked!
So thanks for all the help, I have certainly learnt something about the doctype, and have improved my other pages accordingly.