Web development
Fix HTTP resources on an HTTPS page
Load a secure page’s subresources over HTTPS. An HTTP script, stylesheet, request, or embedded asset can trigger mixed-content blocking or upgrading behavior depending on resource type and browser policy.
Worked example
HTML example · save as example.html and open in a browser
<!-- Keep same-origin resources on the page's secure origin. -->
<link rel="stylesheet" href="/assets/site.css">
<script src="/assets/site.js" defer></script>
<!-- External resources should have an explicitly supported HTTPS URL. -->How it works
Root-relative URLs inherit the page’s protocol and origin. This avoids hardcoding HTTP for your own files. The browser console and network panel can reveal mixed-content requests introduced by embedded HTML, stylesheets, or third-party scripts.
Limits and mistakes
Blindly replacing an external HTTP URL with HTTPS only works if that server supports it correctly. Redirects can also lead back to insecure resources. Do not disable browser protections to make a public site appear functional.
Check the result
Load the deployed HTTPS page with developer tools open. Confirm required resources succeed securely and no script or API call is blocked by mixed-content policy.
Sources
Reference documentation for the behavior used in this guide: