0

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

12
  • Can you show us a diagram/screenshot of your directory structure? Commented Oct 24, 2018 at 10:22
  • href="style/stylesheet.css" should work Commented Oct 24, 2018 at 10:23
  • 1
    There's no way we can tell why this doesn't work from the information you've provided. Open the network tab in your browser's developer tools. Look at the URL that is being requested. Figure out what URL it should work. Work forward from there. Commented Oct 24, 2018 at 10:24
  • 1
    @LakshmanKambam — Why? That's entirely equivalent to what they already have. Commented Oct 24, 2018 at 10:27
  • 1
    @LakshmanKambam — (a) We're talking English nor mathematics here, and (b) even using those definitions, my comments still apply. Commented Oct 24, 2018 at 10:47

2 Answers 2

4

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).

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.