Href without http(s) prefix

It’s possible, and indeed you’re doing it right now. It just doesn’t do what you think it does.

Consider what the browser does when you link to this:

href="https://stackoverflow.com/questions/43803778/index.html"

What then would it do when you link to this?:

href="https://stackoverflow.com/questions/43803778/index.com"

Or this?:

href="www.html"

Or?:

href="www.index.com.html"

The browser doesn’t know what you meant, it only knows what you told it. Without the prefix, it’s going to follow the standard for the current HTTP address. The prefix is what tells it that it needs to start at a new root address entirely.

Note that you don’t need the http: part, you can do this:

href="https://www.google.com"

The browser will use whatever the current protocol is (http, https, etc.) but the // tells it that this is a new root address.

Leave a Comment