dot slash vs nothing. What is the difference and what's better to use?

﹥>﹥吖頭↗ 提交于 2021-02-16 13:45:09

问题


Just for curiosity.

What is the better method to use and what is the difference between them ?

<link rel=stylesheet href="./css/css.css">

vs

<link rel=stylesheet href="css/css.css">

回答1:


In a relative URI, there is no difference between them.

Going without the ./ will save you 2 bytes, so it is marginally better.


In a UNIX style shell, leaving the ./ off will search $PATH while including it will search the current directory. Some people might be including the ./ out of habit from working on the shell.




回答2:


ultimately, there is no difference. They both produce the same link to the same file.

As Quentin just said, it saves you 2 bytes in storage, but I suppose even that doesn't really make a difference.

It just somes down to personal preference/coding style. I never use the ./, never found the use for it. However, people from linux might prefer it, since there it is used to indicate the current directory a lot.



来源:https://stackoverflow.com/questions/22761198/dot-slash-vs-nothing-what-is-the-difference-and-whats-better-to-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!