html - links without http protocol

前端 未结 3 534
灰色年华
灰色年华 2020-11-27 05:32

Is there a reason we include the http / https protocol on the href attribute of links?

Would it be fine to just leave it off:<

3条回答
  •  清歌不尽
    2020-11-27 06:32

    URLs in href are not restricted to only HTTP documents. They support all the protocols supported by browsers- ftp, mailto, file etc.

    Also, you can preceed URL name with '#', to link to a html id internally in the page. You can give just the name or directory path, without a protocol, which will be taken as a relative URL.

提交回复
热议问题