On my computer, the folder that holds my .css and .html file also contains some images that I want to insert in my html. I understand how to get a url for an image if I borrow it from another website. How do I acquire a url for an image that is in my folder, but not yet on the internet? Do I have to upload the image on another website in order to get a link?
I also understand that I should use the base tag in the head to provide a link for my relative urls in the html but at this stage, I don't have a link that contains the images.
Assume your web page(.html
) located in C:\Project\index.html
.
You can place your image in the same path with the web page, and use it with relative path:
<img src="img.jpg"/>
Or if it's in other path, more like some sub folder of your web root: C:\Project\images
:
<img src="/images/img.jpg"/>
If image file is located in the parent folder of your index.html
, use that:
<img src="../img.jpg"/>
The last useage is to use the absolute path, which is not recommended:
<img src="C:/Project/images/img.jpg"/>