user3227878
user3227878

Reputation: 507

Linking to stylesheet in root directory

I am having a major issue trying to link to a stylesheet which is my root directory. I am connecting to it from a HTML file which is in a subdirectory of the root directory.

I would think this code would work (seeing as / means root directory)

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

However, it does not. Because the subdirectory is also only one folder down from the root directory, I also tried:

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

this also does not work.

Upvotes: 3

Views: 2350

Answers (3)

Laurent
Laurent

Reputation: 519

Your first code line should work as "/" really means root :

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

This will find the file https://MY_DOMAIN/style.css

Are you sure that your file style.css is at the root of your project and not in another folder ?

Upvotes: 4

user3227878
user3227878

Reputation: 507

I finally found a solution that works. For whatever reason, I could not link back to the root directory. I am still completely baffled about that, however, I did find a way to make it work.

I did it with this code:

<head>
<link type="text/css" rel="stylesheet" href="http://engagearcade.com/style.css" />
</head>

Upvotes: 0

Andrei Terecoasa
Andrei Terecoasa

Reputation: 572

Also you can try

<style>
    @import url('/style.css');
</style>

Upvotes: 0

Related Questions