Home > Mobile >  How do I link an html file with a CSS file if my HTML file is in a sub directory of a subdirectory a
How do I link an html file with a CSS file if my HTML file is in a sub directory of a subdirectory a

Time:04-09

I started the Free Code Camp projects, but I can't get the CSS file to link with the HTML and I'm sure that I'm missing something that's right in front of me but I can't figure it out.

Here's the structure of my folders: the root folder with the index.html,

A folder named site-content,

another named styles,

Images

and Scripts.

In the site-content folder I have another called projects.

In that file I have the tribute.html page.

What I want to do is connect my tribute.css to tribute.html.

Here's how it looks:

<link href="styles../../../tribute.css" rel="stylesheet">

or: <link href="../../../styles/tribute.css" rel="stylesheet"> I tried with ../ or even ./, I added from 1 to 5 ../ but it still doesn't work and I am lost. What am I doing wrong? Thanks.

CodePudding user response:

If i understood well your file tree look like this:

|-index.html
|--site-content-|
|               |--projects--|
|                            |--tribute.html
|
|--styles-------|
|               |--tribute.css
|--Images
|--Scripts

From "tribute.html" the path to go to "tribute.css" is "../../styles/tributes.css"

<link href="../../styles/tribute.css" rel="stylesheet"> should work

I recommand you to do some research about relative and asbolute path to have a better comprehension about it

  • Related