I don’t know why but i’m struggling so much to add images to my website.
If I have a folder called "images" on desktop with a picture called "eye"
to add that image I would have to do the following code, right?
<img src="Desktop/images/eye.jpg"> ?
I tried
<img src="Desktop/images/eye.jpg">
<img src="images/eye.jpg">
and tried putting in different folders and locations, but idk why it isn’t working
3
Answers
while your html file is in root folder
To put pictures on your website, you need to tell your website where those pictures are. Here’s a simple way to do it if your pictures are in a folder on your computer’s desktop:
Make sure your website’s files are organized. You should have a special folder for your website’s stuff, like your web pages and pictures. For example:
markdown
In your web page (usually named "index.html" or something similar), you can use a special code called an tag to show a picture. But, you need to tell it where to find the picture.
In the tag, you put the path to your picture. It’s like telling your web page, "Hey, look in the ‘images’ folder and find ‘eye.jpg’."
Check Picture Names and Types:
Make sure the picture on your desktop is named exactly "eye.jpg" and that it has the right file type, like ".jpg" (all lowercase, not ".JPG").
If you do these steps right, your picture should show up on your website when you open your web page in a web browser. If it doesn’t, just double-check that your folders and picture names match what you wrote in your web page.
Put the images folders in the same working directory as your HTML project , if your images folder is separate and HTML directory is separate it wont work
<img src="images/eye.jpg" alt="images">