#Help with IMG tag

1 messages · Page 1 of 1 (latest)

regal dirge
#

if i use the Img tag where the image is outside the folder (assets) I would do <img src="..assets/image.png/>. but that doesn't work . However, if I import using react like

<img src={Image}/>``` 
It does. Any idea where im going wrong?
ocean cloak
#

The slash prior to assets to tell its outside the assets folder

cunning rivet
#

It seems like you are missing a quote mark at the end of the url in the first line. Completing the syntax with a quote might make the line work. Also you don't need a forward slash (/) to close the img tag since it is a self-closing tag.
<img src="..assets/image.png">

If this is a project structure related issue you need to identify the parent folder/directory of the file. For example if the image is inside an assets folder, looking something like this : <img src="/assets/image.png">
root
-/assets
-image.png

If the image and assets folder are on the same level, and perhaps in the root directory then you could do something like this : <img src="image.png"> since you don't need to specifically call out the root directory.
root
-/assets
-image.png

Hope this helps!

stray solstice
#

It's because you're missing a / between .. and assets in the first case - in the second case you have it written correctly as ../assets/image.png

And the closing " should definitely be added as @cunning rivet said although browsers are pretty good a picking up this kinds of typos so it may work but still, it should be added.