Regina Shepherd Riddle
Regina Shepherd Riddle

Reputation: 133

How do I make my CSS link up to files in different directories

I am trying to organize my files for my website: The file structure is folders: css | fonts | images | includes | Admin | user | Member - the user folder currently contains the index.php and index.html, search.php, etc. The includes contains the forms I'm trying to get to work with my css.

The css file is inside the css folder. I've tried ../css/style.css and I've tried ..css/style.css and I've tried ../../css/style.css. Nothing I do renders my css. Here is a screen shot of my folder set up:

FILE SET UP

Upvotes: 1

Views: 388

Answers (4)

Parag Tyagi
Parag Tyagi

Reputation: 8960

This is how you should define or structure your static data.

/project_folder
    |-- /static
            |-- /css
                  |-- style.css
                  |-- web289.css
            |-- /js
            |-- /images
            |-- /fonts

And this is how you should define static data in your code.
- Define somewhere (in config) your projects path
- And then always use relative paths for static file

Images:

<img src="/static/images/homepage/xyz.jpg" />

CSS:

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


So answering to your question,
- Keep all the static da.ta in a single folder (as explained above)
- Include it in your code starting from a slash / and then continuing with the folder name and file name

But still if you want to continue with it you can simply use,

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

Meaning, move one folder up there you'll find a css folder inside which you've your css file web289.css

Upvotes: 1

Tanjima Tani
Tanjima Tani

Reputation: 580

use <link rel="stylesheet" type="text/css" href="../css/web289.css" /> as css link as the name of your css is not style.css

Upvotes: 3

Praneeth
Praneeth

Reputation: 79

The name of your stylesheet isn't style.css, its web289.css, you should use this:

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

Upvotes: 1

ayush nigam
ayush nigam

Reputation: 95

you need to import css in your file. It depends on what language you are using. like for HTML you need to write following code: <head> <link rel="stylesheet" type="text/css" href="cssfilename.css"> </head>

Upvotes: 1

Related Questions