+ 61

Why we must use https or http inside href?

Note: I'm not asking about the difference between http and https. Demo program https://code.sololearn.com/WHdb1s0ACG3e/#html in ordinary browser we can type and open fb.com Screenshot image: https://postimg.org/image/uwkgmbbnv/ but inside href we can't use only fb.com we must use https inside href to open fb.com in demo program, if i don't use https or http: FB button redirect to this URL: https://code.sololearn.com/WHdb1s0ACG3e/fb.com not redirect to: fb.com (similar to when we type in the browser) <a target="_blank" href="fb.com" class="icon facebook">Facebook redirect to: https://code.sololearn.com/WHdb1s0ACG3e/fb.com Otherwise: https://fb.com" class="icon facebook">Facebook redirect to: https://fb.com Is it because if we don't decide the internet protocol, it will recognized as file/folder location path current site?

30th Dec 2017, 11:15 AM
Adi Pratama, S.Kom.
Adi Pratama, S.Kom. - avatar
51 Answers
+ 39
# Answer added # To answer your question check the SO link It's due to the various protols employed. think how will the browser differentiate between a file path or some other site link check below link for info. https://stackoverflow.com/questions/8997790/why-does-an-anchor-tags-href-values-need-http-preprended-to-the-url # Edited # @Adi When you edit your post. it should have a text which mentions edited at the top. Reading it and reading the answers seems our posts are off-topic. @Sean While the "S" in https may stand for secure. it's more like private not safe. If you landed on a phishing site. then it does not matter, if you enter data through http/https. it will be dangerous, And unsafe. You need to trust that the site will not be a bad vector. Read below for some info. https://textslashplain.com/2017/01/16/certified-malice/ https://www.troyhunt.com/on-the-perceived-value-ev-certs-cas-phishing-lets-encrypt/
12th Dec 2017, 4:32 AM
Lord Krishna
Lord Krishna - avatar
+ 16
To be technically specific on network requests (addendum to Krishna + SO): The browser must request the correct communication port (it always has to specify one, even though for most people it's done silently). protocol: server probably listening to port number... http: 80 https: 443 ftp: 21 etc...
13th Dec 2017, 3:07 PM
Kirk Schafer
Kirk Schafer - avatar
+ 10
So yes you need to put http, https, or www, just to let browser know that you redirecting user somewhere outside of this site(server), or it will try to find path you specified on current server. It is because each link is just a path to some document and protocol explicitly says that it is other server. By the way it can be any other protocol like ftp or voip.
12th Dec 2017, 5:52 AM
Dima Makieiev
Dima Makieiev - avatar
+ 8
@Adi: You need HTTP <b>OR HTTPS - either is ok. For increased security, use HTTPS. As you suspected, if you don't specify the protocol (HTTP, HTTPS, FTP, etc.), then it will assume that you are referring to something stored locally (i.e on the website's server your HTML file is on), and will attempt to retrieve it from that server. Note: HTTPS does not mean you are going to a safe website, it just means that the communication between the website and you has been privatized. It is not, however, always able to keep people from seeing what you're doing. If you want privacy, most browsers have a private/anonymous/incognito mode. If you want to go a step better, get the real TOR browser and use it with a VPN. @Charan: Either HTTP or HTTPS is fine.
15th Dec 2017, 9:05 PM
Glenn McGrew II
Glenn McGrew II - avatar
+ 8
You use https or http so that SoloLearn will know you are trying to leave the website and go to another. Otherwise it will assume you are redirecting to a file path know as "fb.com"
25th Dec 2017, 9:45 AM
Derek Leiro
Derek Leiro - avatar
+ 6
If you want to redirect your page to a webpage, it becomes compulsory for you to use http or HTTPS because that's the way you differentiate between a website already hosted, and the file location or the new page of your own website. This also follows some hyper text protocols.
15th Dec 2017, 10:42 AM
Divyesh Saglani
Divyesh Saglani - avatar
+ 6
There are absolute and relative link for attribute of src/href. For absolute link, it must be started with http://, https:// or other protocol like ftp://. If the link not start with xxxx:// network protocol formats, it's relative link, so if you set your attribute as href="fb.com/kingdom.pratama" it is link to yoursite.com/fb.com/kingdom.pratama and not to http://fb.com directly.
16th Dec 2017, 4:50 AM
Calviղ
Calviղ - avatar
+ 6
In simple way it is communicator between your machine browser and server http or https is defined protocol of ftp for web or app pages, it tell how pages transfer from your device to server or vice versa.
23rd Dec 2017, 1:15 PM
ravinder singh
ravinder singh - avatar
+ 6
Please consider HTTPS over http. You can secure a site with a ssl, but if you're site's code contains links via http, the ssl padlock will have a warning about insecure/mixed content. Google browsers give security warnings for sites without https, and Google index prioritizes https sites. HTTPS is quickly becoming the standard with the introduction of Let's Encrypt and other free SSL providers. Thus, if you want to code quality sites, be sure to save your clients the trouble of correcting all protocols in the code when they decide to implement https and just go ahead and use https over http. It's best to go ahead and get in the habit of using https or at least a scheme-less URL
25th Dec 2017, 9:18 AM
ScriptKittie
ScriptKittie - avatar
+ 6
missed
25th May 2018, 4:24 PM
Charan Leo25
Charan Leo25 - avatar
+ 5
@Shavat Turakulov Not sure if you're asking, but let's say you had a local Python webserver: // Termux on Android $ python -m http.server Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... Then in the browser you would: http://localhost:8000/ or in a link: <a href="http://127.0.0.1:8000/">click here (0.0.0.0 just means "all addresses for this host", like localhost) Note, requesting https without an actual secure service listening [beyond the scope of this post] will report an error; you can try it -- it's a protocol mismatch on that port (8000).
13th Dec 2017, 4:39 PM
Kirk Schafer
Kirk Schafer - avatar
+ 5
Http and https are just a protocol, like telnet, ftp, mail, etc. You have to be clear about your connection method. Maybe you dont know or you dont use, but there are a lot of protocol for connection.
16th Dec 2017, 11:36 PM
İsmail Taşar
İsmail Taşar - avatar
+ 5
https protocol is much safer than standard http protocol
17th Dec 2017, 1:43 PM
Abhiram ARS
Abhiram ARS - avatar
+ 5
It’s like a secure system for your site
21st Dec 2017, 10:22 AM
sashasoft
sashasoft - avatar
+ 4
use double // //site.com
15th Dec 2017, 6:27 PM
Maxim G
Maxim G - avatar
+ 4
useful stuff
22nd Dec 2017, 7:40 AM
Lesley Chitsika
Lesley Chitsika - avatar
+ 4
http helps in telling browser that it's a file path otherwise it will become system path
22nd Dec 2017, 8:02 AM
Dwij Shukla
Dwij Shukla - avatar
+ 3
https is a bit secured than http
12th Dec 2017, 8:19 AM
Monwabisi Xinwa
+ 3
Google Hyper Text Transfer Protocol Secure (HTTPS) is the secure version of HTTP, the protocol over which data is sent between your browser and the website that you are connected to. The 'S' at the end of HTTPS stands for 'Secure'. It means all communications between your browser and the website are encrypted. https://www.instantssl.com/images/http-vs-https.png
14th Dec 2017, 2:50 PM
#RahulVerma
#RahulVerma - avatar
+ 3
Looks obvious to me... You type it out so that you are sure your viewer goes to the intended webpage.
15th Dec 2017, 12:20 AM
Chris Coder
Chris Coder - avatar