What does “./” (dot slash) refer to in terms of an HTML file path location?

前端 未结 10 1228
北海茫月
北海茫月 2020-11-22 07:17

I know ../ means go up a path, but what does ./ mean exactly?

I was recently going through a tutorial and it seems to be referring to just

相关标签:
10条回答
  • 2020-11-22 08:06
    .  = This location
    .. = Up a directory
    

    So, ./foo.html is just foo.html. And it is optional, but may have relevance if a script generated the path (relevance to the script that is, not how the reference works).

    0 讨论(0)
  • 2020-11-22 08:07

    For example css files are in folder named CSS and html files are in folder HTML, and both these are in folder named XYZ means we refer css files in html as

    <link rel="stylesheet" type="text/css" href="./../CSS/style.css" />
    

    Here .. moves up to HTML
    and . refers to the current directory XYZ

    ---by this logic you would just reference as:

    <link rel="stylesheet" type="text/css" href="CSS/style.css" />
    
    0 讨论(0)
  • 2020-11-22 08:07

    Yeah ./ means the directory you're currently in.

    0 讨论(0)
  • 2020-11-22 08:12

    You can use the following list as quick reference:

       /   = Root directory
       .   = This location
       ..  = Up a directory
       ./  = Current directory
       ../ = Parent of current directory
       ../../ = Two directories backwards
    

    Useful article: https://css-tricks.com/quick-reminder-about-file-paths/

    0 讨论(0)
提交回复
热议问题