'css import <link rel="stylesheet" href="style/style.css"> doesn't work

I'm trying to import a ccs file in HTML. But, it doesn't seem to work.

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

This is my file structure:

enter image description here

If I use the script tag it works. I also tried to use style.css instead of style/style.css but still the same problem.

Any help is highly appreciated!



Solution 1:[1]

Assuming you're putting this in the head section it should work.

Try adding some obvious change to your css to see if it's linking for example:

body {
background-color: red;}

Solution 2:[2]

I don't see in your directory listing where your html files are. But if they're not in the directory above "style", then you'll want to change your link to:

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

i.e. add a slash before "style", so that rather expecting the directory to sit within the current directory of the html, you'll point to the style directory as being at the top level of the site.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rocky
Solution 2 Dave