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" />

  • thenextguy@sh.itjust.works
    link
    fedilink
    arrow-up
    3
    ·
    2 days ago

    Paths don’t have to start with either of those. Just “styles/mystuff.css” is perfectly valid.

    If you start with / the server looks at whatever IT thinks the root folder is, which may not even be visible to your app or site. That’s not what you want most of the time.

    Even at the command prompt you can do “cd styles” without any / or … at all. Try it. If you really want you can probably use “./styles”, where the single dot means the current directory. But you really shouldn’t need it.