Why when i put a img tag on the browser i see a x and not the image? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Why when i put a img tag on the browser i see a x and not the image?

6th Jul 2017, 1:52 PM
Ahmed Gad
Ahmed Gad - avatar
9 ответов
+ 7
if it's on ur pc you would put <img src="file:///C:/......." alt="" /> complete the directory for the image if it's a relative path and u have a folder named "HTML Project" (or whatever) and u have two folders, one html where ur html files r, and one images where the images are, you can simply put <img src="../Images/myImage.jpg" alt="" /> ../ goes up one directory (folder level)
6th Jul 2017, 6:03 PM
MCJEH
MCJEH - avatar
+ 2
Wrong path. It cannot find the image. Check your image path and correct its reference in the src attribute of your image.
6th Jul 2017, 1:53 PM
AgentSmith
+ 2
<img> with 'src' set to a relative urls cannot be render on Sololearn code playground, as source is hosted on Sololearn servers, so relative urls are supposed to be relative to the server, not to your PC: local images can only be displayed if you save and run your html source locally ^^ Even with absolute url and 'file' protocol, your source need to be local, as else the filesystem isn't allowed to scripts (for security: else any JS script could read your files without your permission :P)... Best and pretty only way to include images in Html pages, is to host them anywhere on web (there are plenty of images/files hosters, even free of charge).
7th Jul 2017, 6:56 AM
visph
visph - avatar
+ 1
Dronix, it depends where your images are located in relation to the page that's calling the code. So for example, if it's in an images folder, you may have: src="Images\nameimage.jpg" You need to go locate your image and see what folder it's in. Then set it according to where you stored the image.
6th Jul 2017, 2:01 PM
AgentSmith
+ 1
If the image is just sitting on your desktop, put it into the folder with the rest of your website. You can put it anywhere, but I'd recommend creating an Images folder to make it more organized.
6th Jul 2017, 2:04 PM
AgentSmith
0
Is rhis right? <img src="nameimage.jpg" alt:""/>
6th Jul 2017, 1:56 PM
Ahmed Gad
Ahmed Gad - avatar
0
and if the image in on the desktop?
6th Jul 2017, 2:01 PM
Ahmed Gad
Ahmed Gad - avatar
- 1
you can get image path using windows explorer.
6th Jul 2017, 2:02 PM
Hello Buddy
Hello Buddy - avatar
- 2
src=...
6th Jul 2017, 1:55 PM
Hello Buddy
Hello Buddy - avatar