30

More and more, began to notice that the links in the source code on Web sites begin with two slashes. For example:

<a href="//example.com/1.png">Image</a>

Why do it?

jdphenix
  • 15,022
  • 3
  • 41
  • 74
Kirill Firsov
  • 509
  • 1
  • 7
  • 16

1 Answers1

45

It's a protocol-relative URL (typically HTTP or HTTPS). So if I'm on http://example.org and I link (or include an image, script, etc.) to //example.com/1.png, it goes to http://example.com/1.png. If I'm on https://example.org, it goes to https://example.com/1.png.

This lets you easily avoid mixed content security errors.

jdphenix
  • 15,022
  • 3
  • 41
  • 74
Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539