Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use an <img> element and put the image’s URL path in its src attribute. If index.html and an images folder are side by side, for example, write <img src="images/photo.jpg" alt="Description of the photo">. The path is relative to the HTML document’s URL, not to an arbitrary location on your computer.
Add an image from a child folder
Put the image file in a folder within the directory that contains your HTML file, then use the folder name and filename in src. For this layout:
website/
├── index.html
└── images/
└── photo.jpg
Write this in index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Photo</title>
</head>
<body>
<img src="images/photo.jpg" alt="A description of the photo" width="800" height="600">
</body>
</html>
The src value is a URL path: start with the child folder name, then a slash, then the exact image filename and extension. The alt value should briefly describe the image for people who cannot see it or when the image cannot load. The width and height values are optional; when you know the image dimensions, including them reserves space for the image as the page loads.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Choose the path for your folder layout
Work out where the HTML file sits in relation to the image. A path such as images/photo.jpg starts from the HTML document’s directory. It does not mean “look in a folder called images somewhere on my computer.”
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
| Where the files are | Value for src |
|---|---|
| Image beside the HTML file | photo.jpg |
Image in a child folder named images |
images/photo.jpg |
HTML file in pages; image in a sibling images folder |
../images/photo.jpg |
Image in the same directory
If photo.jpg is alongside the HTML file, you do not need to name a folder:
<img src="photo.jpg" alt="A description of the photo">
Image in a folder one level up
Suppose the HTML file is pages/about.html and the image is images/photo.jpg at the project root:
website/
├── images/
│ └── photo.jpg
└── pages/
└── about.html
From about.html, go up one directory with .., then enter images:
Rank #2
<img src="../images/photo.jpg" alt="A description of the photo">
Each ../ moves up one directory from the HTML file’s location. Count the directory levels needed to reach the folder containing the image, then add the path down to the file.
Use a URL path, not a computer filesystem path
An image reference is resolved from the HTML document’s URL. A path that happens to work on your own computer may not exist on the server after deployment. In particular, do not use a Windows filesystem path such as C:UsersNamePicturesphoto.jpg in a deployed page. Put the image among the site’s served files and use the URL path that matches its location in the deployed site.
Relative paths such as images/photo.jpg are often easier to maintain when a site’s domain changes, because the image reference is based on the document’s location rather than a full domain name. A live site can serve images from the same server as its HTML or through a CDN; whichever arrangement you use, the src must point to an image URL the browser can retrieve.
Rank #3
Write a useful img element
<img> is a void element: it does not wrap image content and does not need a closing tag. Its src identifies the image URL. Include alt text that communicates the image’s relevant content; browsers can show or announce that text when the image cannot be loaded. If the image’s dimensions are known, add matching width and height attributes so the browser can reserve the image’s space while it loads.
<img src="images/photo.jpg" alt="A description of the photo" width="800" height="600">
Use dimensions that reflect the image’s actual proportions. They describe the intended display size in the markup; they are not a substitute for a correct image path. The browser may render the HTML before it has received a larger image file, then update the page when the image arrives.
Publish the image along with the HTML
An <img> element points to an image; it does not copy the file into the page or upload it to your host. Keep the image in the project’s served files and deploy it at the location named by src. For example, if your published page is at the site root and its path is images/photo.jpg, the deployed site needs to expose the file at that corresponding path.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
This matters when the page works locally but the published page shows a broken image. Confirm that the image was included in the deployment and that its deployed name and directory match the HTML. Relative paths are evaluated in the context of each HTML document, so an image reference that works in a root-level index.html may need adjustment in a nested page such as pages/about.html.
Why an image may not appear
Check the path from the HTML file outward rather than changing markup at random. Browsers request the URL named in src; if the file cannot be found at that URL, the image will not display.
- Confirm the folder: Make sure the file is actually in the folder named by the path, including after deployment.
- Match the filename exactly: Check spelling, capitalization, and the real extension, such as
.jpg,.jpeg,.png,.gif, or.webp. - Recount the directory levels: A child folder needs a path such as
images/photo.jpg; a sibling folder reached from a nested page may need../images/photo.jpg. - Remove local filesystem paths: Replace a path such as
C:UsersNamePicturesphoto.jpgwith the URL path exposed by the site. - Check the request: Open the image URL directly in a browser or inspect the page’s network request. A missing-file error indicates that the requested URL does not locate the image.
- Check the element: Confirm that the
imgelement has a validsrcand that its quotes and angle brackets are in place.
Keep meaningful alt text even while troubleshooting: it helps identify the image’s intended content when the file is unavailable and provides an accessibility label.
Best Value
Or skip the browser setup
If what you need is a screenshot of a webpage rather than an image file you already have in a folder, ScreenshotNeo can return a screenshot image or PDF from one GET request. Save the returned image in your project’s images folder, then reference that saved file from your HTML as shown above. This captures a URL; it does not locate or embed an arbitrary image already stored on your computer.
cURL example, saving a WebP screenshot as shot.webp (replace YOUR_API_KEY with your key):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Sign up for 1,000 free screenshots a month—no card required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

