Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just noticed that I can write // instead of and it still works.

Is that some kind of short-hand? Maybe it's something that's built in my browser (Chrome 14)?

Is it safe to use double-slash instead of http and https?

share|improve this question
You could probably just use or or – Rob Sep 29 '11 at 15:52
What @Rob said - I don't think ANY modern browser has required you to put in the http:// in like, 10 years - it's just assumed. (If you want a different protocol from HTTP you do have to enter it.) – Shinrai Sep 29 '11 at 15:53
The question was... why does it work? :D – daGrevis Sep 29 '11 at 15:58
You may also be interested in google then Ctrl+Enter. – RedGrittyBrick Sep 29 '11 at 16:09
@Shinrai: The question was about using a nonstandard // instead of http://, not about omitting it entirely. – grawity Sep 29 '11 at 17:02
up vote 4 down vote accepted

How something like // is handled by the browser will vary by browser. As the standard usage case is http:// and would work across all browsers without a problem.

That being said, the majority of browsers will attempt HTTP where possible since that is what the browsers are used most often for. It is also the safest choice, HTTP traffic is sandboxed as best as possible by the browser and should be more secure than assuming the address is local.

share|improve this answer
I think that nowadays they will even try https:// first. – Simon Verbeke Feb 15 '13 at 21:00
I don't see how this answers the question. It's also unclear what "HTTP traffic is sandboxed" means. – Brandon Dec 27 '14 at 18:54

// is supported in all major browsers. Its very useful when you are developing a web based application and need to write code that works for both HTTP and HTTPS.

You could write for example: <script src="//myscript.js" /> and it will always work no matter which protocol you are using.

share|improve this answer
This should be the accepted answer. – tapananand May 26 at 17:18

I realize this question is old, but the accepted answer does not really answer the question.

Is that some kind of short-hand? Maybe it's something that's built in my browser (Chrome 14)?

Yes, it's a short-hand for whichever protocol the document was served over. It avoids the dreaded "This page contains both secure and nonsecure items. Do you want to display the nonsecure items?" message.

Is it safe to use double-slash instead of http and https?

Yes, all major browsers today support it.

It's generally useless against your own site, but can be very helpful for including resources from other sites (where absolute URL's are needed) but not having to worry about HTTP/HTTPS mix-mode.

It's also helpful if your document is served from both secure and nonsecure locations, like a dev site and production site.

For details, see

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .