+ 1

I want to add image to one of my code.I have tried this <img src="Bottle.jpg"/> as well as pasted the address of img;not working

23rd Oct 2017, 12:40 PM
Ed Sheeran
Ed Sheeran - avatar
3 Réponses
+ 4
'alt' attribute is required, but is also allowed to be missing ^^ If you just put the image file name, the file is loaded from same place (folder/directory) as the html file... in case of code playground running context, you cannot link any local file with your page, as code is executed/load from sololearn servers, so relative url target files from there, not from your device. To be able to link an image to a code playground html page, you need to upload it somewhere on internet and provide the full absolute adress to it (usually starting by 'http://')... Another (heavy) solution is to build an url encoded in base64 text format to embed the image data directly in the html (or css) source code (there are easily findable site doing convert file/picture in base64 text format): https://code.sololearn.com/WljGVfpz1Dp1/?ref=app
23rd Oct 2017, 2:53 PM
visph
visph - avatar
+ 1
Nothing wrong with you're image tag code and you don't need to define the alt attribute to get it to work. The alt attribute is good practice ti help spiders understand what the image is... and also for those on a slow internet connection when the image placeholder loads first showing the image alt tag name. I would strongly suggest looking any the path of the image. Try going to google, opening an image and getting the link for it. Paste that in a see if it display. If so, then you know the code is fines and its just the path. Also one final thing, check your quote (speech) marks within the src attribute.
23rd Oct 2017, 2:48 PM
ihateonions
- 2
try with this <img src="Bottle.jpg" alt=""/> alt is required to display the img. alt is a description in words of the content but you can left that space empty it should work. good luck c:
23rd Oct 2017, 1:09 PM
Aldo
Aldo - avatar