Ivy
Ivy

Reputation: 1

(HTML) linked CSS stylesheet in other folder but same directory doesn't work

I am a total beginner and am trying to create a website and store the CSS stylesheet in a different folder that the HTML files, but in the same directory.

I put this in the header tag of my HTML:

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

but it doesn't work.

The file is in the folder "style" in the same directory as my HTML.

It works, when I have the CSS file and the HTML file in the same folder and link to it in the same way with href="stylesheet.css"

I have looked for other fixes, checked for typos, but it seems to be linked correctly already? I have also tried around different ways to type the path, but nothing works.

This is the way the folders are structured:

directory layout

Upvotes: 0

Views: 2749

Answers (2)

Ifeoluwa Alao
Ifeoluwa Alao

Reputation: 43

According to the image structure you have there i think you should do something like this

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

This should work just fine

Upvotes: 1

Quentin
Quentin

Reputation: 943142

The file is in the folder "style" in the same directory as my HTML.

No, it isn't.

The image shows that the HTML is in a folder named LoggedIn, and the CSS is in a folder called style but style is not inside LoggedIn. It is a sibling directory of LoggedIn not a subdirectory of it.

So you need to go up a level before you go down into style.

Replace ./ (the current directory) with ../ (the parent directory).

Upvotes: 4

Related Questions