2022 October, 18
What is the difference between the URLs https://domain and //domain?
2 Minutes to read
The primary difference is that https://domain specifies the protocol HTTPS explicitly, while //domain inherits the protocol from the current webpage. Using //domain is a good practice to maintain consistency with the current page’s protocol and reduce potential security issues related to mixed content.
- Absolute URL
-
URLs of type
https://domainare absolute URLs, meaning they explicitly include the protocol or scheme — in this casehttps://. When you use this format, you specify that the website should be accessed over HTTPS, a secure protocol for web communication. The browser will use the HTTPS protocol to connect to the specified domain. - Protocol-relative URL
-
URLs of type
//domainare protocol-relative URL or network-path references. It does not explicitly specify a particular protocol as HTTP or HTTPS. Instead, it inherits the protocol used in the current webpage.
If the current webpage is loaded over HTTPS, the browser will use HTTPS to connect to the domain. If the current webpage is loaded over HTTP, it will use HTTP. Protocol-relative URLs often ensure that resources are loaded securely when a webpage can be accessed over HTTP and HTTPS without causing mixed content issues (for example loading insecure resources on a secure page).