While learning about paths I found out that "/" takes you to the root directory. I made .html and .css files in the same directory to test how it behaves for different paths. When linking the css file, href = "app.css" and href = "./app.css" both work fine but when I try href = "/app.css" it doesn't link. I know "/" is suposed to take you to the root directory and from what I understand the directory of the html file is the root directory. So why isn't the css file linking properly?
/ means the root of the current drive
./ means the current directory
../ means the parent of the current directory
No need to add the "/" or "./" because your app.css file is in your current directory.
Related
Im trying to host a github live server for a project that right now has a "index.html" main folder with 4 files inside that main folder named "forgot-pass.html" "home.html" "sign-in.html" "sign-up.html"
I know to host on github your html needs to be a index.html but my question is can you have a folder named index.html with html files inside that folder and it still work? or how can i host on github if i have multiple html files named various things.
Yes you can have more html files in the same folder or subfolders, but it's mandatory to have the "index.html" file. Also I think you can make that folder but will not work (I don't know if it works or not, but give it a shot).
Its required to have a "index.html" file located in the root directory. As far as having a main FOLDER named index.html with files inside of that as-well, did not work for me. but i did not try to have a index.html file in the root directory on its own ALONG with a separate folder containing the rest of the html files. So i don't know if that works or not. i just put all the html files in the root directory and made sure to have one named "index.html"
I have index.html file in "WTProject" Folder. I've created 404.html in "404" Folder which is in "WTProject". It simply go to 404.html from index.html.
but I don't know how to go back to WTProject Folder to access index.html.
I mean what should I write in Home so that it will go in previous directory and open index.html.
You can use ../ to access previous directory in HTML. For usage check out: https://www.w3schools.com/html/html_filepaths.asp
I have a website:
www.mydomain.com/panel/abcde.html
I don't remember the difference between ./ and ../
./ is used to return in the first level?
Instead ../ is used to simulate all domain?
.../ exists?
I believe it is like this :
/ = root of the currently location
./ = current directory
../ = parent of current directory
Reference could be found here
/ is the root folder of the filesystem.
./ usually denotes the current folder that your program or script is in, usually the same one with the file you run.
../ denotes the folder above the current one.
.../ Does not exist. If you type that on terminal, it will throw error No such file or directory
I'm confused as to when the following are used and what they mean, for example in the src attribute of an img tag.
I know / means 'current directory' and ../ means 'up one directory'
. Current Directory? <a href="." />
./ Current Directory <img src="./image.png" />
/ Root directory <img src="/image.png" />
../ Up one directory <img src="../image.png" />
What is the difference between ./image.png and /image.png
Updated: / means root directory of the site
/ means starting from the root directory. Whereas ./ is the current directory, though I'm not sure there's any need for it (unless you're planning on appending to a PATH in Linux systems... happy to be wrong about that one).
./image.png will grab image.png relative to your current location. Calling ./image.png on domain.tld/site/page.html will look for the image at domain.tld/site/image.png
/image.png will look for the image in the root of your site. domain.tld/image.png
You could also use things like ../images/image.png. If this was used on domain.tld/site/page.html, the browser would load the image from domain.tld/images/image.png
The / means the root directory. Use . For the current directory.
I'm editing a file in a folder in my root directory.. here's a quick tree:
root
- images
- m
- - index.php
If I want to grab the images folder from index.php, how would I go about doing that? I've tried:
../images
I want to eliminate having to use my website URL.
you should use /images instead of ../images if you know the image directory is in the root. this will resolve to a directory named images in the root from any path.
eg if you are on page /pages/html/MyPage.html the path /images will still resolve to the images directory in root whereas ../images would resolve to /pages/images.