HTML <img src> wont load my images
Categories:
Troubleshooting HTML <img>
Tags: Why Your Images Aren't Loading

Learn to diagnose and fix common issues preventing images from displaying in your HTML, covering file paths, server configurations, and browser caches.
One of the most fundamental elements of web design is displaying images using the HTML <img>
tag. However, it's a surprisingly common frustration for developers, especially beginners, when images simply refuse to load. This article will guide you through the most frequent causes of <img>
tag failures and provide systematic solutions to get your visuals back on screen.
Understanding the src
Attribute and File Paths
The src
attribute is the most critical part of the <img>
tag, as it tells the browser where to find the image file. Incorrectly specifying this path is by far the leading cause of images not loading. Paths can be absolute (a full URL) or relative (based on the current HTML file's location).
flowchart TD A[HTML File] --> B{Is `src` Absolute?} B -->|Yes| C[Browser requests URL] B -->|No| D[Is `src` Relative?] D -->|Yes| E[Browser calculates path from HTML file] D -->|No| F[Error: Invalid Path] C --> G{Image Found?} E --> G G -->|Yes| H[Image Loads Successfully] G -->|No| I[Error: Image Not Found (404)]
Decision flow for browser image loading based on src
attribute.
<!-- Relative path: image in the same directory as HTML -->
<img src="my-image.jpg" alt="A beautiful landscape">
<!-- Relative path: image in a 'images' subfolder -->
<img src="images/my-image.png" alt="A detailed diagram">
<!-- Relative path: image one level up from HTML -->
<img src="../assets/logo.gif" alt="Company logo">
<!-- Absolute path: full URL -->
<img src="https://example.com/images/hero.webp" alt="Hero image from example.com">
Examples of absolute and relative paths in <img>
tags.
Image.JPG
and image.jpg
as different files.Common Pitfalls and Solutions
Beyond incorrect paths, several other factors can prevent images from loading. These often involve server configuration, browser behavior, or even simple typos.
1. Incorrect File Name or Extension
Even a single character typo in the file name or extension (.jpeg
instead of .jpg
, .PNG
instead of .png
) will prevent the browser from finding the image. Double-check the exact spelling and casing.
2. Server-Side Issues and Permissions
If your HTML and images are on a web server, ensure the image files have the correct read permissions. If the server cannot read the file, it cannot serve it to the browser. Also, check server logs for 403 Forbidden or 404 Not Found errors.
3. Browser Cache
Sometimes, a browser might cache an old version of your page or an old 'broken' state of an image. A hard refresh (Ctrl+F5 or Cmd+Shift+R) can often resolve this by forcing the browser to re-download all assets.
4. Ad Blockers or Browser Extensions
Aggressive ad blockers or privacy extensions can sometimes block images, especially if their filenames or URLs resemble advertising content. Temporarily disabling extensions can help diagnose this.
5. Network Issues or Slow Loading
On occasion, the image might be too large, or the network connection too slow, causing the image to time out before fully loading. Check the browser's developer console (Network tab) for loading times and potential errors.
alt
attribute with descriptive text. This is crucial for accessibility (screen readers) and provides a fallback text if the image fails to load, improving user experience and SEO.Debugging with Browser Developer Tools
The most powerful tool for diagnosing image loading issues is your browser's developer console. It provides real-time feedback on network requests, errors, and element properties.
1. Open Developer Tools
Right-click on your web page and select 'Inspect' or 'Inspect Element' (or press F12 / Cmd+Option+I).
2. Check the Console Tab
Look for error messages related to image loading, such as 'Failed to load resource: the server responded with a status of 404 (Not Found)' or 'net::ERR_FILE_NOT_FOUND'.
3. Examine the Network Tab
Refresh the page with the Network tab open. Filter by 'Img' or 'Images'. Look for your image file. If it's listed, check its 'Status' code (e.g., 200 OK means loaded, 404 Not Found means path is wrong, 403 Forbidden means permission issue). You can also see the 'Initiator' to understand what requested the image.
4. Inspect the Element
In the Elements tab, find your <img>
tag. Hover over the src
attribute value. Most browsers will show a tooltip with the resolved path or even a preview of the image if it loaded correctly. If it shows a broken image icon, the path is likely incorrect.