Jay
Jay

Reputation: 31

img src="" not showing image

I am writing a very basic webpage, while doing so I am trying to put an image on one of the pages. I am using HTML and this is what I have so far:

 <div id ="div4"><img src="file:///Users/me/Documents/image.jpg" 
width="460" height="460"/></div>

I am using Brackets editor and when I use the preview option, the image shows up blank with a symbol in the top left corner. If you can let me know what i am doing wrong that would be great. Thanks!

Upvotes: 1

Views: 6151

Answers (3)

blurfus
blurfus

Reputation: 14031

If image.jpg is in the same folder as your HTML page, then you can use a relative path to load the image: <img src="./image.jpg" />

For example, if file structure is like this:

parent folder
 |
 +- index.html
    image.jpg

Of course, you can adjust the path according to the image's location in relation to the HTML page.

Upvotes: 0

Jaxon Crosmas
Jaxon Crosmas

Reputation: 477

It looks like something it wrong with the filepath.

If the img is in the same file as the html document, use this

<img src="image.jpg">

If the img is in a different folder, use ../ to go back from the current folder like this

<img src="../differentfolder/image.jpg">

(As well, in brackets you can hover over the img filepath in the code to display a preview of the image. If the filepath is correct, the image should appear)

Upvotes: 0

Mooseman
Mooseman

Reputation: 18891

Most browsers block access to any file:// URL's if the page is being loaded over any other protocol such as http://.

Upvotes: 3

Related Questions