Skip to content

Mixed content: an HTTPS page that loads over HTTP

mixed-contentserious
On this page

Why it matters

  • Scripts, stylesheets, frames, icons and subtitles: browsers block them on HTTPS pages, since anyone on the way could change them, so the page breaks or loses its styles. So too images chosen by srcset or <picture>, and images on an IP address rather than a domain name.
  • Other images, video and audio: browsers that follow Mixed Content Level 2, Chrome and Firefox among them, ask for them over HTTPS instead, so they vanish when they are not there. Other browsers load them and show the page as not secure.
  • Forms: what the visitor types, such as a password or a phone number, is sent in the clear, and browsers warn before sending it.

Example

Wrong
<img src="http://shop.example/images/halwa.jpg" alt="علبة حلوى عمانية" width="400" height="300" />
Right
<img src="/images/halwa.jpg" alt="علبة حلوى عمانية" width="400" height="300" />

How to fix

  • Change http:// to https:// in resource addresses, or use paths that start with / on the same site.
  • For a resource on another site that does not work over HTTPS: move it to your site, or replace it.
  • Content-Security-Policy: upgrade-insecure-requests has the browser ask for every http: address over HTTPS, forms included, so the page passes this rule. The addresses are still wrong wherever the HTML is read without it, so fix them too.

How we detect

  1. The rule applies to HTTPS pages.
  2. We read the page's HTML for elements that load over http:: script, iframe, object, embed, link for stylesheets and icons, and img, srcset, video, audio, source and track; and for forms that send to http: (action, and formaction on a form's submit button).
  3. We resolve each address as the browser does, including what <base> changes, and read srcset as HTML does. A script the browser does not fetch, such as nomodule or a template, does not count.
  4. A page that asks for upgrade-insecure-requests, in a Content-Security-Policy header or in a <meta> in <head> before the element, passes: the browser fetches each address over HTTPS. A Content-Security-Policy-Report-Only header upgrades nothing.
  5. We do not check what scripts add to the page after it loads.