skip to Main Content

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


  1. <img src="images/eye.jpg" alt="Eye Image">
    

    while your html file is in root folder

    Login or Signup to reply.
  2. 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:

    1. Folder Setup:

    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

    - YourWebsiteFolder/
      - index.html
      - images/
        - eye.jpg
    
    1. Put Pictures in HTML:

    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.

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Your Website</title>
    </head>
    <body>
        <h1>Welcome to My Website</h1>
        <img src="images/eye.jpg" alt="Eye Image">
    </body>
    </html>
    

    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.

    Login or Signup to reply.
  3. 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">

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search