Trouble Linking index.html to css folder in 16.04 [closed]

I've built an Apache2 webserver in 16.04. Currently, my index.html is located in /var/www/html/index.html. I try to call some css using this line:

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

The file basic.css is located at /var/www/css/basic.css. I figure my href is wrong. Any help would be much appreciated.

1 Answer

you have to place your css folder in the html folder so /var/www/html/css/... you can do this by

sudo mv /var/www/css /var/www/html/css


OR you have to reference href="../css/basic.css"

But usually you should prefer the first way.

Anyway in both cases make sure you have the rights set correctly e.g. by

sudo chown -R <username>:www-data /var/www/html/css

or in the second case

sudo chown -R <username>:www-data /var/www/css
4

You Might Also Like