Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between using "http://" and just "//" in src or href?

Tags:

html

http

I've seen some sites use //somedomain.com/images/img.jpg vs using http://somedomain.com/images/img.jpg which includes the http: as well.

Is there a difference between the two? Is the browser just correcting the missing http: and these people are being lazy? Im curious behind the reasoning.

like image 203
chadley Avatar asked Jul 08 '10 23:07

chadley


1 Answers

If you are already on the site via http, it will assume you are talking about http and connect to the same server via the same protocol. Same with https. If you are on http and want to go to https, you would need to specify the protocol in the href.

like image 93
rakuo15 Avatar answered Oct 07 '22 13:10

rakuo15