Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Programming Frameworks Generating "//" for Links

Tags:

html

http

Lately I've noticed that a lot of web programming frameworks are using a // in front of certain generated href and src links

//example from twitter.com
<a href="//support.twitter.com">Help</a>

Is this just a shortcut for http/https, or something more?

Does anyone know where this technique got its start and if there's a browser support matrix that confirms/describes the behavior of the leading //?

like image 721
Alan Storm Avatar asked Apr 20 '12 17:04

Alan Storm


1 Answers

It's protocol-relative URL best described by Paul Irish; http://paulirish.com/2010/the-protocol-relative-url/

Basically if you use protocol relative URL's (links that start with "//" instead of "http://" or "https://") you can avoid the "This Page Contains Both Secure and Non-Secure Items" pop-up in Internet Explorer (and possibly on other browsers as well). You can use that in .css files, too, simply by changing "http://" or "https://" to "//".

like image 196
Chris Avatar answered Sep 19 '22 14:09

Chris