# Mixed content

What is mixed content?

Mixed content means resources, such as images, scripts or stylesheets, that a page loaded securely over [HTTPS](/glossary/https) fetches over plain HTTP. The page itself arrived encrypted, but those resources did not, so an attacker on the way can view or change them.

## How it works

MDN divides mixed content into two groups, by what browsers do with each today:

- Upgradable content: images set with `<img src>` (not through `srcset` or `<picture>`), and `<audio>`, `<video>` and `<source>`. Browsers change the request from `http` to `https` by themselves. The server then answers with the resource, or with a status saying it was not found.
- Blockable content: everything that is not upgradable, including scripts, stylesheets, iframes, `fetch()` and XMLHttpRequest calls and web fonts. Browsers block these requests.

A request that would be upgraded is blocked instead when its host is an IP address rather than a domain name. Earlier versions of the specification used other groups: "active" mixed content, such as scripts, which browsers had to block, and "passive" mixed content, such as images, which they could block or show.

A site can ask for its insecure resource requests to be upgraded with the `upgrade-insecure-requests` directive of a [content security policy](/glossary/content-security-policy):

```http
Content-Security-Policy: upgrade-insecure-requests
```

It upgrades blockable content too. MDN warns that a resource that is not available over HTTPS then fails, without falling back to HTTP.

## Why it matters

A resource fetched over HTTP can be viewed and modified on the way. MDN singles out scripts as particularly dangerous because they can change any part of the page, and notes that even an altered image can mislead, for example by changing what a button appears to do. That is why browsers block most of it, and a blocked script or stylesheet means part of the page stops working.

## What can go wrong

- A site moves to HTTPS, but content stored in its database still holds hard-coded `http://` URLs for images and files.
- A third-party widget loads its script over HTTP, the browser blocks it, and the feature it provides disappears from the page.
- An image is linked by IP address, so it is blocked rather than upgraded.
- An image is upgraded to HTTPS, but its host does not serve it there, and the page shows a gap.

## Check it

Browse the site with the developer console open: MDN notes that it shows a warning each time mixed content is upgraded or blocked. Lighthouse's "Does not use HTTPS" audit can fail on an HTTPS page because of mixed content, and the Security section of the Privacy and security panel in Chrome DevTools helps you find the requests behind it.

Read this definition in a browser: https://ranetrace.com/glossary/mixed-content
