16
submitted 3 days ago* (last edited 3 days ago) by Crumpled6273@lemmy.ca to c/programming@programming.dev

Am trying to learn web development by creating a website my own instead learning every single theory written on a textbook.

Currently am trying to link a stylesheet and favicon on my root folder into the file called debian.html and debian-post-install.html. But it's not working and I don't know why.

code used inside both html files head section are,

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

<link rel="icon" type="image/png" href="/images/favicon.png" />

To point to the root directory files or directories we use / in html instead of ../ right? Then why it's not working.

Also I need advice on how bad is my html file structuring and what changes recommended.

Solution

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

<link rel="icon" type="image/png" href="../../images/favicon.png" />

you are viewing a single comment's thread
view the rest of the comments
[-] Crumpled6273@lemmy.ca 4 points 3 days ago* (last edited 3 days ago)

In stack overflow i saw,

/ = root of the current drive, ./ = current directory, ../ = parent of the current directory.

What exactly is this .../ ?

Btw, I solved it by writing the path like this,

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

<link rel="icon" type="image/png" href="../../images/favicon.png" />

Thank you for taking time to answer me.

[-] Hemuphone@lemmy.world 1 points 3 days ago

/ being root directory does not apply to the web browser.

.../ means nothing, as its not defined. Results may vary based on interpreter, but nothing useful.

On href, I think all 3: style.css, /style.css, ./style.css point to the same place.

[-] cypherpunks@lemmy.ml 2 points 2 days ago

On href, I think all 3: style.css, /style.css, ./style.css point to the same place.

no, they do not. (click for details)

those three do not always resolve to the same thing: the first and last are relative, while the second is absolute.

from a file at http://example.com/index.html, all three would resolve to http://example.com/style.css.

But from a file at http://example.com/foo/index.html the href="style.css" and href="./style.css" will both resolve to http://example.com/foo/style.css while href="/style.css" will continue to resolve to the file at the root (http://example.com/style.css).

[-] Hemuphone@lemmy.world 2 points 2 days ago

Interesting! TIL.

this post was submitted on 10 Oct 2026
16 points (94.4% liked)

Programming

28795 readers
182 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS