/    Sign up×
Community /Pin to ProfileBookmark

IMG problem. But why?

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

to post a comment
HTML

12 Comments(s)

Copy linkTweet thisAlerts:
@cfajohnsonSep 16.2009 — 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;
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
[/QUOTE]
[indent]

Why Transitional? What are you transitioning from? If it's a new page use HTML 4.01 Strict.

[/indent]<i>
</i>&lt;HTML&gt;
&lt;HEAD&gt;
&lt;Title&gt;Test&lt;/title&gt;
&lt;/HEAD&gt;
&lt;Body&gt;

&lt;IMG SRC="http://www.example.com/images/myimage.gif" ALT="ama" /&gt; &lt;br&gt;
&lt;IMG SRC="http://newsimg.bbc.co.uk/media/images/46136000/gif/_46136662_gazabomb226index.gif" ALT="test" /&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;

The first IMG tag does not work.[/QUOTE]
[indent]

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.

[/indent]
Copy linkTweet thisAlerts:
@WebJoelSep 16.2009 — "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

is actually meaningless without the also-require [B]URI address[/B] that 'supplies' the rules for it:

example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" [B]"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[/B]>

(worth noting, in XHTML strict, the "html" needs to be [I]lowercase[/I] as I have here)

:-)
Copy linkTweet thisAlerts:
@dj_jay_smithauthorSep 16.2009 — 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
Copy linkTweet thisAlerts:
@cfajohnsonSep 16.2009 — [indent]

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.

[/indent]
Copy linkTweet thisAlerts:
@CoyotelabSep 16.2009 — is this a yahoo store template?

Give the image width="" and Height=""
Copy linkTweet thisAlerts:
@dj_jay_smithauthorSep 17.2009 — Hi,

Well I tried that and still have problems. My URL is http://www.wishindex.com/test.html

Jason
Copy linkTweet thisAlerts:
@cfajohnsonSep 17.2009 — [indent]

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?

[/indent]
Copy linkTweet thisAlerts:
@dj_jay_smithauthorSep 17.2009 — 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?
Copy linkTweet thisAlerts:
@CharlesSep 17.2009 — Could it be a permissions problem?[/QUOTE]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.
Copy linkTweet thisAlerts:
@dj_jay_smithauthorSep 17.2009 — Well I set the rights for the directory and file to 777 but it doesn't help!
Copy linkTweet thisAlerts:
@kiwibritSep 17.2009 — 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?
Copy linkTweet thisAlerts:
@dj_jay_smithauthorSep 18.2009 — 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.
×

Success!

Help @dj_jay_smith spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...