A direct image URL for HTML and CSS
Half the “my image does not show up” tickets on any web project come down to the same thing: the URL points at a page about the image instead of the image itself. This page shows what a direct URL looks like, how to verify one, and the attributes worth adding once it works.
Upload and get a direct URL Convert to WebP first
Direct versus indirect
| URL | What it returns | Usable in img src? |
|---|---|---|
https://chuantu.de/2026/12/abc123.png | The file itself (image/png) | Yes |
https://example.com/view/abc123 | An HTML page that displays it | No — you get a broken image |
https://example.com/abc123 (redirect) | 302 to the file | Usually yes, but costs a round trip |
The quick test: open the URL in a new tab. If you see the picture alone on a white page with no header, no caption, no buttons, it is direct. If you see anything else, it is not.
The markup that works
Minimum viable image tag:
<img src="https://chuantu.de/2026/12/abc123.png" alt="Editor toolbar before saving">
In practice you want four attributes, because they decide layout stability, accessibility and whether the browser can pick a smaller file:
<img src="https://chuantu.de/2026/12/abc123.png"
alt="Editor toolbar before saving"
width="1200" height="675"
loading="lazy" decoding="async">
- width / height — the browser reserves space before the file arrives, so the page does not jump while it loads. The numbers are the image’s intrinsic size, not the display size; CSS can still scale it down.
- loading="lazy" — images below the fold stop competing with the ones the reader can actually see.
- alt — required for screen readers, and it is what shows if the host ever goes away.
CSS
A background image needs the same direct URL:
.hero {
background-image: url("https://chuantu.de/2026/12/hero.webp");
background-size: cover;
background-position: center;
aspect-ratio: 16 / 9;
}
Two notes. First, background-size: cover on an element without a defined height collapses to nothing — give the element an aspect-ratio or a height. Second, CSS background images are not honoured by screen readers, so if the picture carries meaning, use an <img> instead.
Responsive images
<img src="https://chuantu.de/2026/12/shot-1200.png"
srcset="https://chuantu.de/2026/12/shot-600.png 600w,
https://chuantu.de/2026/12/shot-1200.png 1200w,
https://chuantu.de/2026/12/shot-1800.png 1800w"
sizes="(max-width: 700px) 100vw, 700px"
alt="Dashboard overview">
Export the widths with the resize tool, upload each one, then paste three URLs. It is more work than a single file, and it is the difference between a 400 KB payload and a 90 KB one on a phone.
Email templates
Email clients are a decade behind browsers. In HTML email:
- use absolute
https://URLs — relative paths do not exist in an inbox; - set
widthas an attribute, not only in CSS — Outlook ignores much of modern CSS; - assume images are blocked until the reader clicks “show images”, so never put essential text inside the picture;
- keep the file under about 100 KB — some clients and corporate gateways cap total message size.
Common reasons a correct URL still fails
| Symptom | Cause |
|---|---|
| Works in browser, broken on the page | Page served over HTTPS, image over HTTP — mixed content is blocked |
| Shows for you, not for others | URL points at something on your machine or an internal host |
| Broken after copying from a chat app | Messenger shortened or wrapped the URL; copy from the original page |
| Blank space with the right size | Host returns 403 to hotlinking from a different referrer |
| Works on desktop, not on mobile | Huge file plus aggressive mobile data saving; resize it |
Hosts that block hotlinking are the most common surprise. This one does not: direct links are meant to be embedded, which is the entire point of the service. See the FAQ for limits.
FAQ
- Do the links have a file extension?
- Yes —
.png,.jpg,.gif,.webp. That extension is a useful sanity check that you copied a file URL. - Can I use the URL in a CMS image field?
- If the field accepts a URL rather than an upload, yes. Some CMSs re-fetch and re-host the file on save, which is also fine.
- Is there a size limit for embedded images?
- The upload limits are per tier and shown on the FAQ page. For web pages, the practical limit is much lower — aim under 200 KB per image.
- Do I need an account?
- No. Guests can upload and copy a direct URL immediately; an account adds management and higher limits.