Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 5

CSS not being applied in pages :/

Hello eveyone,

 

I am new to github. I've been following tutoials etc on how to set up pages. Now, i'm trying to move my codepen HTML and CSS over here. HTML is working, but CSS is not being applied. 

 

I'm obviously doing something wrong. But I can't figure it out.

 

https://github.com/noethix/trial

 

Thank you in advance fo any pointers.

 

Cecile

4 Replies
Highlighted
Pilot Lvl 1
Message 2 of 5

Re: CSS not being applied in pages :/

Hi @noethix,

 

Looking at your page, it appears the issue is the "/" at the beginning of your stylesheet's source. Change "/css/main.css" to "css/main.css" (on line 5 of index.html) and it should fix the issue you're having.

 

For future reference, if the html file is in the same directory as another folder or file, you don't need to include a slash at the beginning of the src or href attributes. Also, if you need to access files up one, two, or however many directories, you can use two periods as a substitute. (example below)

 

say our folders are..

root --> resources --> stylesheet.css

root --> lessons --> lesson-1 --> exercise-1 --> index.html

 

For our html file to access the stylesheet we could provide the following.

<link rel="stylesheet" href="../../../resources/stylesheet.min.css">

Basically two ".." moves up a directory and since index.html was three directories down, we moved up three times until we were in the root thus able to access the resources folder. You can also reference the current directory with "./".

 

If any questions, let us know.

Copilot Lvl 3
Message 3 of 5

Re: CSS not being applied in pages :/

Thank you @SethClydesdale for your detailed answer and the tips ! But it didn't work either...

Community Manager
Message 4 of 5

Re: CSS not being applied in pages :/

CSS appears to be working when I look at https://noethix.github.io/trial. Do you see it as working now? Or can you describe what is not working for you?

Ground Controller Lvl 1
Message 5 of 5

Re: CSS not being applied in pages :/

Thank you, that helped me so much; not only for CSS but also for IMAGE directories (I used to work with underline before its names, like: "_css or _image").

So, I had to took them off and changed on HTML and CSS as well so it could work.