1

I have used <img> tag in html for displaying images. The image gets displayed in Internet Explorer 10, but it is not visible in mozilla, chrome. Could someone please tell me the reason why?

    <img src="file:///d:/maruthi.jpg" style="width: 150px; height: 140px;" alt="Photo">
Steve
  • 8,469
  • 1
  • 26
  • 37
Code Break
  • 137
  • 1
  • 2
  • 7
  • 2
    Have you tried browsing to that location in Firefox? Also, thats a local path so it will only work on your machine. –  Jun 14 '13 at 04:19
  • Could someone please tell me what 2 downvotes do in a perfectly valid question? Instead of downvoting, why don't you answer his question? – Not Amused Jun 14 '13 at 04:28
  • I didn’t downvote, but the question title is rather absurd as such. Firefox wouldn’t be used if it didn’t support `img`. This is about `file:` URLs and not `img`. – Jukka K. Korpela Jun 14 '13 at 06:14
  • This is a valid question, the title was misleading so I've edited. However, this is really a dupe anyway... – Steve Oct 09 '14 at 14:48
  • possible duplicate of [Firefox Links to local or network pages do not work](http://stackoverflow.com/questions/192080/firefox-links-to-local-or-network-pages-do-not-work) – Steve Oct 09 '14 at 14:49

5 Answers5

3

Chrome stops access to local file:// links from with in http:// page for security reasons by default.

Ashish Patil
  • 818
  • 7
  • 15
1

file:// is not allowed in Chrome and Firefox for security reasons by default, but this answer shows you how to change those settings. Really, you should set up a lightweight local server.

Community
  • 1
  • 1
foobarbecue
  • 6,780
  • 4
  • 28
  • 54
  • Not even for about: or data: urls that are entered into the url bar, or set as home page. Which is amazingly stupid, and hence perfectly fits the mentally ill state of the WhatWG. – Evi1M4chine Jan 25 '18 at 09:20
0

The <img> tag is standard across all browsers (except text-based browsers like Lyx). That should work, however given that it is a local path it may be that you are testing it in a different environment that can't access that path?

Review this wikipedia page on the file URI scheme and it will also highlight that some browser will limit access to local files for security reasons.

0

The original title to OP's question is NOT misleading - it is perfectly valid. However, they did not say whether they were using Windows or Linux. Windows and Windows programs (like DOS from which they originated) are completely indiscriminate with regard to the use of upper or lower case in filenames.

Two possibilities to consider:

  1. Linux is fully case sensitive, including its use of filenames. Yourfile.JPG is NOT recognized as being the same as Yourfile.jpg! I recently migrated from Windows to Linux and encountered exactly the same problem with Firefox. It displayed images in sites on the internet, but not in perfectly valid local HTML and CSS markup. Later, I noticed that the Windows image-editing program I'd been using had saved all the images with uppercase .JPG or .PNG extensions. A few that I'd previously renamed manually had lowercase extensions - these DID display normally! Linux 'properties' for those files identified them correctly as JPEG files, while those with uppercase extensions were simply identified as IMAGE. Also, my markup references all images with lowercase extensions (professional usage). When non-displaying image file extensions were changed to lowercase, they all displayed correctly.

  2. If Steve is still using Windows, it's possible that Internet Explorer is displaying local images for the same reason as above. Firefox, though, uses a different engine (Mozilla) and, being open-source, maybe more strict with regards to case sensitivity in file names. However, I'm not in a position to check this out. Maybe someone else can test.

  • Sorry - forgot to mention that, if Steve is still using the tag with included CSS style references in his HTML markup, he should consider moving all detail style references to external style sheets. These can be referenced simply in the HTML markup as id='YourName' or class='YourName'. The resultant markup is noticeably cleaner – Bro Lyndon Oct 22 '20 at 01:56
  • You can always edit your question instead of writing a comment. – Pochmurnik Oct 22 '20 at 05:52
  • Practical reason for using external style sheets is that changing a single external style declaration for a given attribute is much simpler than having to change the same style on multiple HTML pages! Also, when an external page containing a batch of style declarations is loaded, it remains in memory for the session, so that subsequent HTML pages that use the same styles load much faster! (This doesn't relate to the problem in hand, but may be of some help to @Code Break, who asked the original question?) – Bro Lyndon Oct 22 '20 at 07:30
-2

i have used in jsp as this : and working in firefox and chrome

            <a href="Welcome.jsp"><img src="home.jpg">
Emmanuel Angelo.R
  • 1,545
  • 2
  • 16
  • 24