Put a PNG on an HTML page with an <img> element and set its src attribute to the image’s reachable path or URL:
<img src="images/photo.png" alt="A red kite flying over a field">
Use a relative path for a file in your site, or an absolute https:// URL for an image hosted elsewhere. Add useful alternative text and known dimensions, then use srcset or picture only when you need responsive sizes, viewport-specific sources, or format fallbacks.
The basic PNG image element
The HTML img element embeds an image. Its src value identifies the image URL or path; at least one of src or srcset is required. The element is a void element, so it has no closing tag. See MDN’s img reference for the element’s current attributes.
<img src="images/photo.png" alt="A red kite flying over a field">
The browser requests the value in src. The PNG must be available at that address; placing a filename in HTML does not upload or copy the file.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
PNG beside the HTML file
<img src="logo.png" alt="Company logo">
This works when the page and logo.png are in the same directory.
PNG in a child directory
<img src="images/logo.png" alt="Company logo">
If your page is in the project root and the file is in a sibling images folder, use the folder name followed by the filename.
PNG in a parent directory
<img src="../images/logo.png" alt="Company logo">
.. moves up one directory from the page’s URL location. Add another ../ for each additional level, but prefer a predictable public asset folder in larger projects.
PNG at an absolute URL
<img src="https://example.com/assets/logo.png" alt="Example company logo">
An absolute URL is resolved independently of your page’s directory. Use a URL that visitors can reach; a path such as C:UsersSamPictureslogo.png points to your computer, not to a file on a public website. MDN explains relative and absolute image URLs in its HTML images tutorial.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteHow relative paths are resolved
A relative src is resolved from the page URL, not necessarily from the folder you currently have open in your editor. For example, if the page is served as https://example.com/blog/post.html, images/photo.png normally requests https://example.com/blog/images/photo.png. Moving the HTML file or changing the server’s URL base can therefore change which file the browser requests.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
- Identify the URL of the page in the browser.
- Start at that page’s directory when writing a relative path.
- Match every directory, filename, and extension exactly.
- Open the resulting image URL directly in a browser to confirm it is reachable.
Servers commonly treat capitalization as significant. Photo.png, photo.png, and photo.PNG may be different files. Keep the path URL-friendly and avoid relying on spaces or unusual punctuation.
Write alt text that helps people
The alt attribute is the image’s text alternative. Describe the image’s meaningful content or purpose in the page’s context, rather than repeating a filename or writing “image.” The MDN image guidance covers alternative text and image dimensions.
<img src="images/kite.png" alt="A red kite flying over a field at sunset">
For an image that conveys information, include the detail a reader needs. If the image is purely decorative and its purpose is already conveyed elsewhere, use an empty alternative, alt="", so assistive technology does not announce an irrelevant filename. Do not omit alt accidentally: decide whether the image is informative or decorative.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Reserve space with width and height
When the intrinsic dimensions are known, include both width and height:
<img src="images/photo.png" alt="A red kite flying over a field" width="1200" height="800">
These attributes describe the file’s intrinsic dimensions. The browser can reserve the appropriate space before downloading the image, reducing unexpected layout movement. CSS can still control the displayed size:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
.hero-image {
display: block;
max-width: 100%;
height: auto;
}
Do not invent dimensions merely to fill attributes. Obtain the actual pixel dimensions from the image or your asset pipeline.
Choose the right markup for one or many PNGs
One fixed image: use img
A single PNG at a known URL needs only img, with alt and dimensions when applicable.
Free tools Windows power users keep installed
One-click scans. No signup required.
Several resolutions: use srcset and sizes
When you publish multiple widths of the same image, srcset gives the browser candidates and sizes describes the expected display slot when you use width descriptors:
<img
src="images/photo-800.png"
srcset="images/photo-400.png 400w,
images/photo-800.png 800w,
images/photo-1600.png 1600w"
sizes="(max-width: 600px) 100vw, 800px"
width="1600"
height="1067"
alt="A red kite flying over a field">
The browser chooses among the candidates. Keep the ordinary src as a fallback for clients that do not select a srcset candidate. Ensure every listed URL exists; a typo in one candidate can produce a broken image at only some viewport sizes.
Different conditions or formats: use picture
Use picture when the source should change for a media condition or when you want to offer another image format. The nested img remains the fallback:
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
<picture>
<source media="(max-width: 600px)" srcset="images/photo-crop-small.png">
<source type="image/webp" srcset="images/photo.webp">
<img src="images/photo.png" alt="A red kite flying over a field" width="1600" height="1067">
</picture>
The MDN image-format guide describes format selection. Keep the fallback img valid because it is the image used when no source matches or a format is unsupported.
Keep a PNG from overflowing its layout
HTML attributes provide intrinsic dimensions; CSS controls presentation. A responsive rule prevents a large PNG from exceeding its container:
img {
max-width: 100%;
height: auto;
}
Scope the rule to a class if other images on the page need different behavior. Do not set only a new width while leaving a fixed, unrelated height; that can distort the image. Using height: auto preserves its aspect ratio.
Test the path before debugging the markup
- Save the HTML file and make sure the PNG is inside the directory served by your web server or development tool.
- Copy the exact value of
srcand open it directly in the browser. - If the direct URL fails, correct the directory, filename, extension, or capitalization before changing HTML.
- If the direct URL works, inspect the page’s resolved request in browser developer tools and compare it with the working URL.
- Check the page over the same protocol and host visitors will use; an image available only on your local computer is not a deployable asset.
Troubleshoot a broken PNG
The image icon appears, but no picture loads
- Check the relative path from the page URL, not from your editor’s workspace root.
- Confirm the file exists at that URL and that the extension and capitalization match.
- Open the image URL directly. A not-found or access response identifies a hosting or path problem.
- Look for an empty
srcor a typo introduced while editing.
MDN lists empty sources, inaccessible data, corrupted files, and unsupported formats among possible causes of image failures; see the img troubleshooting notes.
The image works locally but not after deployment
Deployment often changes the page URL, directory structure, or filename case. Check the deployed page’s source URL and request the deployed image address directly. Upload the PNG to the site’s publicly served assets instead of referencing a local filesystem path.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteBest Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Only some responsive images fail
Test each URL in srcset and each matching source in picture. A valid fallback does not repair a missing candidate that the browser selected. Also verify that the sizes expression describes the actual layout slot.
The file is present but appears corrupted
Try opening the original PNG in an image viewer and re-exporting it if necessary. A damaged file or problematic metadata can fail even when the URL is correct. Replace it with a known-valid PNG and retest the same markup.
When an automated screenshot is easier
If your goal is to capture a rendered page containing the PNG rather than hand-author an img tag, ScreenshotNeo can return a PNG, JPEG, WebP, or PDF from one GET request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and whether the request was billed.
Or skip the browser setup
Use the ScreenshotNeo API with an access key. The API documentation lists all options, including full-page capture, lazy-image loading, CSS-selector element capture, dark mode, device presets, retina scale, PDF settings, custom CSS or JavaScript, clicks, waits, blocked resources, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous webhooks, bulk capture, and usage data.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots each month without a card; paid plans start at $5 for 3,000 shots. Sign up for the free plan to try it.
Practical checklist
- Use
<img>for a single PNG. - Set
srcto a reachable relative path or absolute URL. - Write contextual
alttext, or usealt=""for purely decorative artwork. - Include the real intrinsic
widthandheightwhen known. - Add
srcsetandsizesfor multiple resolutions. - Use
picturewith a valid fallbackimgfor media or format choices. - Open the resolved image URL directly when debugging.
Frequently Asked Questions
Does an img element need a closing tag?
No. img is a void HTML element, so write its opening element and attributes without </img>.
Can I reference a PNG that is not in my HTML file’s folder?
Yes. Use a relative path such as ../images/photo.png or a reachable absolute URL. The relative path is resolved from the page URL.
What should I do if I have only one PNG size?
Use a normal img with its src, meaningful alt text, and intrinsic dimensions when available. Add responsive candidates only when you actually publish additional files.
Recommended Free Tools
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.

