How to add image from local files


I have used vs code and tried to open my html file through chrome but the image is not showing in the html file opened in chrome. what is the solution?

For that example, the file must be in the SAME folder as the html file

<!DOCTYPE html>
<html>
    <head><title>Test</title></head>
    <body>
        This is my special image
        <img src="example.jpg"/>
    </body>
</html>

image
image

If the file is in a folder, then the src would be different

        <img src="img/example.jpg"/> <!-- looks in a folder img at the same level of the html page -->
        <img src="../img/example.jpg"/> <!-- looks for a folder img on level up from the folder holding the html page-->
        <img src="/img/example.jpg"/> <!-- looks in a folder img at the root of the website -->

1 Like