The description of Yandex.Metrica explicitly says that URLs like //mc.yandex.ru/metrika/watch.js (no http: in front) that the web site owner has to insert into his pages are not erroneous. So for example this code:

<img src="//mc.yandex.ru/watch/00000"
     style="position:absolute; left:-9999px;" alt="" />

is claimed to be okay.

However the code validator thinks such URLs are not okay and I'd rather make the validator happy so that noone breaks the code later trying to "fix" it.

Why are these URLs not prepended with http:? What happens if I actually prepend them with http:?

  • 1
    Unless this is simply a typo in your question, the (HTML?) validator fails because you are missing a " from the start of the attribute value. This has nothing to do with the structure of the URL. What code validator are you using?
    – MrWhite
    Aug 26, 2012 at 12:07
  • @w3d: That was a typo. I use the built-in validator of Visual Studio 2010 code editor.
    – sharptooth
    Sep 10, 2012 at 7:50

1 Answer 1


I think the code validator is wrong. If part of a URL is missing then the other parts are filled in from the parent page. So for example, if an image is referred to from http://example.org/page1.html with src="pic.jpg" then the browser adds http://example.org/ before the src.jpg before it fetches the file. If the http: part of the url (the protocol) is missing then the protocol on the parent page will be used.

Why are they not prepended with http:? I'm guessing it's because if you have an https:// page then the images will automatically be delivered via https.

If you actually prepend them with http: and you have an https page then, depending on the browser, the user may get an error message saying that some of the content on the page isn't secure.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.