Use an HTML <img> element with a valid src and an appropriate alt value. For example, src="images/photo.jpg" loads a file relative to the HTML document; an absolute HTTPS URL can load an image from another server. Add intrinsic dimensions to reserve space, and use srcset with sizes when the browser should choose among image resolutions.
Use an <img> element for a single image
“Importing” an image into HTML usually means embedding it in a page, not importing a module. The WHATWG HTML Standard’s Images section says: “To embed an image in HTML, when there is only a single image resource, use the img element and its src attribute.” The section was updated 16 September 2026.
<img src="images/photo.jpg" alt="A red bicycle leaning against a brick wall" width="800" height="600">
Save this in the HTML where the image should appear. Replace the example path and description with values that match your file and page. The image element is a void element: it does not have a closing </img> tag.
Use a relative path for a file in your project
A relative URL is resolved from the HTML document’s URL, not necessarily from the project folder or the location of a CSS file. For a simple project such as:
#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.
project/
index.html
images/
photo.jpg
the element in index.html can use src="images/photo.jpg". If the HTML file is in a subfolder, adjust the path from that file. For example, an HTML file at pages/about.html would refer to the same image with src="../images/photo.jpg".
A leading slash, as in src="/images/photo.jpg", points to a path from the website’s root. That can be useful on a deployed site, but it may not work as expected when you open a page directly from disk or deploy the site under a subdirectory. Choose a path that matches how and where the page will be served.
Use an absolute URL for a remote image
<img src="https://cdn.example.com/photos/photo.jpg" alt="A red bicycle leaning against a brick wall" width="800" height="600">
The remote address must be reachable and return an image resource that is suitable for <img>. A URL to an HTML page that displays an image is not the same as a URL to the image file. Check that you have permission to use a remote image and consider whether relying on another server is acceptable for your page.
Write useful alternative text
The alt attribute provides a textual fallback if the image cannot be displayed and an equivalent for people who cannot process the image. Describe the information or function the image contributes in its page context; do not use its filename as a substitute. A photograph that is meaningful to the page might use alt="A red bicycle leaning against a brick wall".
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.
Mark decorative or redundant images as decorative
If an image adds no information beyond nearby text, or is purely decorative, use an empty alternative: alt="". This is different from omitting the attribute. Decide based on the image’s role in context: the same picture could need a description in one page and be redundant in another.
Describe the purpose, not every visual detail
Keep the description relevant to what the reader needs from the image. If an image is also a link or control, its alternative should communicate the action or destination rather than merely list visual details. Avoid phrases that add no useful information and do not put a file path in the description.
Choose responsive images with srcset and sizes
When you have multiple versions of the same image at different resolutions, srcset lets the browser choose a candidate. Width descriptors such as 400w and 800w indicate the pixel width of each file. With width descriptors, provide sizes so the browser can estimate how wide the image will appear in the layout.
<img
src="photo-800.jpg"
srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1200.jpg 1200w"
sizes="(max-width: 600px) 100vw, 800px"
alt="A red bicycle leaning against a brick wall"
width="800"
height="533">
Here, the candidates are 400, 800, and 1,200 pixels wide. The sizes value describes a slot that can fill the viewport up to 600 pixels wide and is otherwise 800 CSS pixels wide. Make that description match your actual layout: an inaccurate slot estimate can lead the browser to choose an image that is larger or smaller than needed. The ordinary src remains a fallback candidate.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, 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 minuteRank #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.
The srcset attribute can also use pixel-density descriptors such as 1x and 2x when the alternatives are intended for different display densities. Do not mix width and density descriptors in the same candidate list. Use width descriptors for layout-responsive images and density descriptors when the displayed size is fixed but image sharpness should vary.
Use <picture> for art direction or format alternatives
Use <picture> when the page needs to offer alternate image sources, such as a different crop for a viewport or modern formats with a fallback. Each <source> gives the browser a candidate; the nested <img> is required and supplies the fallback and alternative text.
<picture>
<source type="image/avif" srcset="photo.avif">
<source type="image/webp" srcset="photo.webp">
<img src="photo.jpg" alt="A red bicycle leaning against a brick wall" width="800" height="533">
</picture>
The browser considers the declared sources and falls back to the nested JPEG image if none is usable. For actual art direction, provide different crops or compositions as appropriate candidates; a format-only set, as above, offers alternate encodings of the same visual. Keep the fallback image’s text alternative and dimensions accurate.
Reserve layout space and control loading
Set width and height to the image’s intrinsic dimensions. Browsers can use their ratio to reserve the right-shaped space before the file arrives, reducing unexpected layout movement. These attributes do not mean the image must display at that exact CSS size; responsive CSS can scale it while preserving its ratio.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsRank #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
<img src="images/photo.jpg" alt="A red bicycle leaning against a brick wall" width="800" height="600" loading="lazy">
Use loading="lazy" for suitable images below the initial viewport, where delaying the fetch until the image is near view can avoid unnecessary early loading. Keep important above-the-fold images eager unless there is a clear reason to defer them. Do not lazy-load every image by default: an image a visitor needs immediately should not wait for a later scroll.
The HTML Standard also defines decoding values (sync, async, or auto), fetchpriority, referrerpolicy, and crossorigin. These control aspects of decoding, fetch priority, referrer information, or cross-origin requests; they are optional and should be chosen for a specific need rather than added mechanically. crossorigin is relevant when a third-party image is used with a canvas, and the server must permit the cross-origin access required for that use.
Use a valid image resource
The src must identify a valid, non-empty image resource. HTML image use covers static and animated bitmap formats and single-page vector resources. A scripted or interactive SVG, a multipage PDF, an HTML document, or plain text is not a conforming image resource for <img>. If the URL opens a page that happens to contain an image, use the image file’s URL instead.
Troubleshoot an image that does not appear
- Check the final URL. Open or inspect the resolved address and confirm it points to the intended image, not an HTML page or a different route.
- Check spelling and case. The deployed path and filename must match the URL, including capitalization.
- Check deployment location. Confirm the file was included in the deployed site at the path your HTML references. A path that worked from a local folder may resolve differently after deployment.
- Inspect the network response. In browser developer tools, examine the image request for a missing-file response or an incorrect content type. A server can return an error page even when the URL looks plausible.
- Check the resource type. Confirm the address serves a supported image rather than a document, multipage PDF, or interactive resource.
- Check remote access. A third-party host may not serve the file at that URL or may not permit the access your use requires. Verify the address and the server response.
Generate an image of a web page without configuring a browser
For a photograph or illustration you already have, use the HTML patterns above. If what you need to place in a page is instead a screenshot of a live website, ScreenshotNeo can return an image or PDF from a single GET request. It is a website screenshot API and MCP server for developers; the API can create the screenshot asset, while your HTML still uses an ordinary <img> element to display it.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best 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.
Example cURL request, using the API’s documented endpoint and parameter format:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Then place the saved file in your site’s deployed assets and reference its path in HTML, for example <img src="images/shot.webp" alt="Screenshot of the Stripe homepage" width="800" height="600">. The dimensions and alternative text here are examples; use values and a description appropriate to the actual capture. See the ScreenshotNeo documentation for request options and setup.
Equivalent Python request:
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)
Equivalent Node.js request:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Node.js example makes the request; add your own response handling and file-writing code if you want to save the returned image locally. Protect the API key: do not expose it in public browser-side HTML or JavaScript.
Or skip the browser setup
ScreenshotNeo handles capture through an API request rather than requiring you to set up a browser for this job. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Plans include the product’s features, and yearly billing gives two months free.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Sign up free for 1,000 screenshots a month, with 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.

