skip to Main Content

I am trying to do something very simple and display an image I scraped off the web using HTML.
For some reason, it’s not working.

<!DOCTYPE html>
<html>
<body>

<h2>HTML Image</h2>
<img src="headline1.jpg" alt="headline" width="500" height="333"></img>

</body>
</html>

My project structure:

What I’m seeing on my localhost

I’ve tried changing the image location (src), changing it to a png, changing the image size. Can’t quite figure out what’s going on

4

Answers


  1. I think the image tag don’t need of closing tag.

    Replace the code

    <img src="headline1.jpg" alt="headline" width="500" height="333"></img>
    

    With below code:

    <img src="headline1.jpg" alt="headline" width="500" height="333">
    
    Login or Signup to reply.
  2. This should normally work if you open index.html in a browser. However, if you are using something like Django (given that you have a folder named templates), I suggest you try to learn how static files like images are served in Django:

    Django: How to manage static files (e.g. images, JavaScript, CSS)

    Login or Signup to reply.
    • Image element doesn’t have end tag
    <img src="headline1.jpg" alt="headline" width="500" height="333"/>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search