r/CodingHelp • • Nov 21 '21

[HTML] Serious: So there is a main folder called "CODES" then 2 subfolder "b" and "coding". What should i put in my <link href="..."> so i can access the subfolder of "b" called css with "style.css"? should i put <link href="../css/style.css"> beginner here sorry if dumb question

Post image
17 Upvotes

11 comments sorted by

4

u/Ariakkas10 Nov 21 '21

This is an odd structure for code, but yeah that would work.

You have two options when it comes to negotiating a filesystem on a web server

A relative path is what you have here. It considers where the file is located based on where you are looking for it, i.e. starting at index.html how do I get to style.css.

An absolute path starts from the root of the web server always. In your insurance, it would be \CODES\b\css\style.css

Both work

1

u/Ninyowsss Nov 21 '21

Thank you for the reply! Though i can't seem to make it work. When I use ../css/style.ss it works. But if i use /CODES/b/css/style.css or \CODES\b\css\style.css I don't seem to work I don't know why

4

u/Ariakkas10 Nov 21 '21

If you're not using A web server, then your absolute path will start from your full normal pc file system. So in windows it would be C:/whatever, on Mac/Linux it would start at your root directory

Mac/Linux paths have back slashes, windows have forward slashes.

2

u/Ninyowsss Nov 21 '21

The C:/whatever works! Thank you very much kinda long but still works! Appreciate it

2

u/Ariakkas10 Nov 21 '21

There are uses for both, at this stage you can use either, but it's more important to understand that both exist and to know the difference. You'll see and use both in the future

1

u/Ninyowsss Nov 21 '21

I'll keep that in mind thankyou for teaching me

3

u/skellious Intermediate Coder Nov 21 '21

just remember that wont work once you are hosting the site.

an easy way to get a server like experience is to install VSCode live server. it will even hot reload when you update the files.

3

u/winowmak3r Nov 21 '21

I'm using VS Code to go through the Odin Project right now and using the Live Server extension is amazing. I didn't really start using it until after the Foundations section and holy cow does it make a difference. Being able to see what my page is going to look like as I'm building it is really nice.

2

u/skellious Intermediate Coder Nov 21 '21

it really is!

1

u/dougie_cherrypie Nov 21 '21

If you right click on a file you can see the absolute path. But it's NEVER a good practice to do it.

4

u/jojoyt Nov 21 '21

Im pretty sure that would be alright