Mixed content is the situation in which a page delivered over secure HTTPS loads subresources over insecure HTTP, such as scripts, stylesheets, images, media, fonts or API calls. On the Web, this breaks the guarantee that everything the user sees and runs came encrypted and unaltered from the origin, because any HTTP request can be read or modified by an attacker on the network path.
Modern browser technologies treat mixed content as a security defect. Browsers block most insecure requests by default, automatically upgrade others to HTTPS and flag the page in the address bar, so fixing mixed content is a standard step in every migration from HTTP to HTTPS.
Why mixed content undermines HTTPS
HTTPS protects a page through TLS encryption and server authentication, but that protection covers only the requests made over TLS. When the HTML document is secure and a script arrives over HTTP, a man-in-the-middle attacker on public Wi-Fi or a compromised router can replace that script and gain full control of the page, including its cookies, forms and displayed content.
The risk depends on what the insecure resource can do. A script runs with the privileges of the secure origin, while an image can at most be swapped or observed. This difference is the basis of the browser rules described in the W3C Mixed Content specification.
| Insecure resource | What an attacker can do | Severity |
|---|---|---|
| Script | Execute arbitrary code in the secure origin | Critical |
| Stylesheet | Alter layout, hide warnings, exfiltrate data via CSS selectors | High |
| Iframe | Inject a phishing frame inside a trusted page | High |
| Fetch or XHR request | Read or modify application data | Critical |
| Image | Replace the picture, track the visit | Moderate |
| Audio or video | Swap media, reveal what the user watches | Moderate |
Active and passive mixed content
The Mixed Content specification divides insecure resources into blockable and upgradeable content, often called active and passive mixed content. Blockable content can affect the whole page, so browsers refuse to load it. Upgradeable content has limited reach, so browsers rewrite its URL to HTTPS and load it only if the secure version exists.
| Category | Typical elements | Default browser behavior |
|---|---|---|
| Blockable (active) | script, link stylesheet, iframe, fetch, XHR, WebSocket over ws | Blocked, console error logged |
| Upgradeable (passive) | img, audio, video, source | Rewritten to HTTPS, fails if unavailable |
| Insecure form action | form posting to an http URL | Warning before submission or blocked |
| Insecure downloads | File links over HTTP from a secure page | Warning or block in Chromium-based browsers |
Older browsers displayed passive mixed content with only a warning icon instead of the padlock. Since about 2020, Chromium, Gecko and WebKit have converged on autoupgrade plus blocking, which means that a missing HTTPS version of an image now results in a broken image rather than an insecure one.
Mixed content and related browser security policies
Mixed content rules work alongside other browser security mechanisms, and they are easy to confuse. The mixed content check looks only at the scheme of each subresource, whereas the same-origin policy and CORS govern which origins may read each other’s data.
| Mechanism | Question it answers | Relation to mixed content |
|---|---|---|
| Mixed content blocking | Is this subresource fetched securely | Core subject of this page |
| Same-origin policy | May this origin read another origin’s data | Independent; secure cross-origin loads are allowed |
| CORS | Has the server permitted cross-origin access | Cannot override mixed content blocking |
| HSTS | Must this host always use HTTPS | Prevents insecure loads to listed hosts |
| upgrade-insecure-requests | Should HTTP URLs be rewritten automatically | CSP directive that removes most mixed content |
Finding and fixing mixed content
The reliable fix is to serve every resource over HTTPS and reference it correctly. Detection starts in the developer tools console, where browsers log each blocked or upgraded request, and continues with crawlers that scan all pages, because mixed content often hides in old posts, templates and third-party embeds.
- Enable HTTPS on every host that serves assets, including CDNs and media subdomains.
- Replace hard-coded HTTP URLs in templates, databases and configuration with HTTPS or relative paths.
- Add the Content-Security-Policy directive upgrade-insecure-requests as a safety net for legacy URLs.
- Use Content-Security-Policy-Report-Only to collect reports of remaining insecure requests before enforcing stricter rules.
- Enable HSTS once all content is secure, so browsers never request the site over HTTP again.
Protocol-relative URLs that start with two slashes were once recommended, but they are now considered an outdated pattern. Explicit HTTPS references are clearer and avoid surprises when pages are saved locally or rendered in unusual contexts.
Common mistakes and symptoms
Most mixed content incidents appear after a site moves to HTTPS or when external content is embedded. The symptoms are often visual rather than obvious security errors, which makes the cause easy to overlook.
| Symptom | Likely cause | Fix |
|---|---|---|
| Page loads without styling | Stylesheet linked over HTTP | Update the link to HTTPS |
| Interactive features stop working | Script or API endpoint over HTTP | Serve the endpoint over HTTPS |
| Broken images in old articles | Absolute HTTP URLs stored in the database | Run a search and replace on stored content |
| Embedded widget is empty | Third-party iframe without HTTPS | Switch provider or use its HTTPS embed |
| Padlock missing or warning shown | Insecure form action or passive resource | Correct the URL and retest |
A frequent misconception is that a valid TLS certificate alone makes a page secure. The certificate protects only the connections that use it, so a page with a perfect certificate can still be fully compromised through one insecure script.
Understanding it simply
Mixed content is like a sealed envelope that contains an unsealed note from someone else. The main letter arrives safely, but anyone along the way could have read or changed the loose note before it was slipped inside.
When a secure website pulls in even one picture or piece of code through an unprotected connection, that piece becomes the weak point. Browsers therefore block or upgrade those pieces automatically, and website owners fix the problem by making sure every part of the page travels over the secure connection.
Applied in practice
A small online shop moves from HTTP to HTTPS after installing a free certificate. The home page shows the padlock, yet customers report that the checkout button does nothing. The developer opens the browser console and finds that the payment script is loaded from an HTTP address hard-coded in an old theme file, and the browser has blocked it.
A crawl of the full site also reveals about 1,200 product images with absolute HTTP URLs stored in the database. The developer updates the theme, runs a database search and replace, and adds the upgrade-insecure-requests directive as a fallback. After a week with report-only monitoring shows no remaining insecure requests, HSTS is enabled.
The result is a fully secure storefront with working checkout, consistent padlock indicators in every browser and no broken product images.