Search code examples
htmlcsshyperlinkrelative-path

html relative address to css style sheet not working


I have a linux folder structure as follows for an apache server on a raspberry pi:

/var/www/html/index.html
/var/www/css/style.css
/var/www/php/someCode.php

index.html is as follows:

<!DOCTYPE html>
<html>
<head>
 <title>Introducing CSS Not Working</title>
 <link href="../css/style.css" type="text/css"
 rel="stylesheet" />
</head>
<body>
 <h1>From Garden to Plate Not Working</h1>
 <p>A <i>potager</i> is a French term for an
 ornamental vegetable or kitchen garden ... </p>
 <h2>What to Plant</h2>
 <p>Plants are chosen as much for their functionality
 as for their color and form ... </p>
</body>
</html>

style.css is as follows:

body {
font-family: Arial, Verdana, sans-serif;}
h1, h2 {
color: red;}
p {
color: #665544;}

The css isn't impacting the html. Have you any idea why, I'm guessing something to do with the css link in index.html?


Solution

  • css file is out of root directory, I'd move it into the same directory where the index.html is or if you need css folder I would create them like this

    /var/www/index.html
    /var/www/css/style.css 
    /var/www/php/someCode.php