Links start with two slashes [duplicate]
Asked Answered
M

1

31

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?

Menefee answered 1/9, 2011 at 16:44 Comment(0)
I
46

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.

Instigation answered 1/9, 2011 at 16:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.