Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking to stylesheet in root directory

Tags:

css

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.

like image 550
user3227878 Avatar asked Feb 02 '26 07:02

user3227878


1 Answers

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 ?

like image 114
Laurent Avatar answered Feb 05 '26 00:02

Laurent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!