Kanha_ji
Kanha_ji

Reputation: 93

Img Src tag in Html not Working regardless any reference link type

I was editing an HTML page and had some issue in replacing image. It didn't displayed anything.
Then I tried making a simple HTML program just to test

<html>
<head>
<title>
</title>
</head>
<body>

<img src="/images/Kanhaji.jpg" alt="HTML5 Icon" width="128" height="128" />


</body>
</html>

but it still doesnot work. I tried Everything Including but not limited to
1. Giving local links in same directory in which my page is.
2. Creating a subDirectory and giving its link.(as shown above)
3. Giving full path
4. using <image src="./Kanhaji.jpeg" /> (proper reference methods ./ ../ etc)
5. Using an Online Link <image src="https://I_cannot_remember_the_url_exactly />
6. Hard Refreshing page ctrl + f5 in case if browser is using cached contents somehow.
But nothing seems to work only a box,where image is supposed to appears, with a broken image icon appears.
<img class="rounded-circle img-fluid d-block mx-auto" src="http://placehold.it/200x200" alt="">
the above code is working fine

after watching it working , i tried to
7.remove extension of file if it is effecting somehow but that also didn't helped

Can anyone help me with this problem.

Upvotes: 0

Views: 2508

Answers (4)

Kanha_ji
Kanha_ji

Reputation: 93

Okk guys i Think There was a problem with my browser.. when i tried this answer ... it failed to open directly as well.. i reinstalled Firefox and its working now.. but was not able to found the cause of problem

Upvotes: 0

Satyam Singh
Satyam Singh

Reputation: 188

You are missing . Before the /image. It's leads to the subfolder where your image is kept.

<img> src="./images/Kanhaji.jpg" alt="HTML5 Icon" width="128" height="128"/>

Upvotes: 0

AdyDev
AdyDev

Reputation: 106

Open your image in a browser and you can see real path in address bar, if you testing in localhost... and tell us about your path for a help you.

Upvotes: 1

tommybravo
tommybravo

Reputation: 1

The above html structure should be fine. I'd recommend checking the following:

  • Whether the server has altered your code and replaced the URL of the image in the html.
  • Is the image itself in a folder on the server that is publicly accessible? What happens if you just type the complete URL of image to the location bar of your browser?
  • Confirm that the name of the file and filename in the "src" tag are the same. I misspelled filenames more times than I would like to admit (first capital letter vs. all smallcaps).
  • Check the file type. Even if the extension says "jpg", it might have a different format, and some browsers may fail to recognize it.

Anyway, if you could provide the url of your site, it would be helpful.

Upvotes: 0

Related Questions