Lo que hace"./ "(dot slash) se refiere en términos de una ubicación de ruta de archivo HTML?


Sé que ../ significa subir por un camino, pero ¿qué significa ./ exactamente?

Recientemente estaba pasando por un tutorial y parece que se refiere a solo un archivo en la misma ubicación, por lo que es necesario en absoluto? ¿Puedo simplemente no usarlo si eso es todo lo que está haciendo?

Author: GibboK, 2011-09-29

8 answers

./ es la carpeta en la que se encuentra el archivo de trabajo:

Así que en /index.htm ./ es el directorio raíz
pero en /css/style.css ./ es la carpeta css.

Esto es importante de recordar porque si mueve CSS de /index.htm a /css/style.css la ruta cambiará.

 100
Author: Coomie,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-30 20:40:13

/ significa la raíz de la unidad actual;

./ significa el directorio actual;

../ significa el padre del directorio actual.

 221
Author: Rahul,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-05 22:17:15

Puede utilizar la siguiente lista como referencia rápida:

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

Artículo útil: https://css-tricks.com/quick-reminder-about-file-paths /

 65
Author: GibboK,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-11-18 07:31:17
.  = This location
.. = Up a directory

Entonces, ./foo.html es solo foo.html. Y es opcional, pero puede tener relevancia si un script generó la ruta (relevancia para el script es decir, no como funciona la referencia).

 51
Author: Brad Christie,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-09-29 00:47:16

Sí, ./ significa el directorio de trabajo actual. Solo puede hacer referencia al archivo directamente por su nombre, sin él.

 31
Author: Brad,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-09-29 00:46:25

Tienes razón en que puedes omitirlo. Es útil solo para la claridad. No hay diferencia funcional entre estar allí y no estar allí.

 9
Author: Genia S.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-09-29 00:47:36

Por ejemplo, los archivos css están en la carpeta llamada CSS y los archivos html están en la carpeta HTML, y ambos están en la carpeta llamada XYZ significa que nos referimos a los archivos css en html como

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

Aquí .. se mueve hacia HTML
y . se refiere al directorio actual XYZ

- - - por esta lógica solo se referiría como:

<link rel="stylesheet" type="text/css" href="CSS/style.css" />
 2
Author: Jenifer Venitta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-28 03:29:40

Yeah ./ significa el directorio en el que se encuentra actualmente.

 0
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-09-29 00:59:44