CSS Not Working with Addtional Pages...

User 563328 Photo


Registered User
85 posts

I created my external CSS file and put the link in my index.html page. Everything works great. However when I create a second page and use the link, <link rel="stylesheet" type="text/css" media="screen" href="css/main-styles.css" /> it seems to work fine in preview until I save the page. Once I have saved the file none of the CSS settings take effect. It just defaults to plain text with no color or alignment settings.

I have tried it as a snippet, cut & paste, and entering manually and it still doesn't work.
User 2000538 Photo


Registered User
1,392 posts

Is the link code in the head section?

I'm not sure but maybe having a hyphen in the name might be having an effect. Generally an underscore would be used if you need a space in a name.
I know you believe you understand what you think I said...but I am not sure you realize that what you heard is not exactly what I meant.


User 117361 Photo


Ambassador
6,076 posts

I thought I just answered this one... where did that disappear to?
I was asking if you were sure to have included the css link in the additional pages too, and to check which folders the pages are in relation to the css file.

And have you got an url address for us to look at?
User 563328 Photo


Registered User
85 posts

Good Morning tassietiger,

Yes the link code is in the head section. And acutally the hyphen in the post was a mistake. The actual file name has an underscore.


Kelly
User 2000538 Photo


Registered User
1,392 posts

Kelly Horst wrote:
Good Morning tassietiger,

Yes the link code is in the head section. And acutally the hyphen in the post was a mistake. The actual file name has an underscore.


Kelly


Okay that's good. So now we need to turn to Janys's questions ...
I know you believe you understand what you think I said...but I am not sure you realize that what you heard is not exactly what I meant.


User 563328 Photo


Registered User
85 posts

Janys,

I don't have it up on the internet yet. I did put the link on the second page (in the head section). As far as which folder - here is how my project is broken down:

Frank-Kolb-Russia (project name)
index.html
subfolder-CSS with my external CSS - Main_Styles.css
subfolder-FRANK
subfolder-History
subfolder-Images
subfolder-KOLB
subfolder-Miscellaneous
subfolder-Resources with second page - database_background.html

My lind code - <link rel="stylesheet" type="text/css" media="screen" href="css/main_styles.css"/>

Kelly




User 2000538 Photo


Registered User
1,392 posts

Make sure the folder name, css file name and the link all have lower case letters for their names.
I know you believe you understand what you think I said...but I am not sure you realize that what you heard is not exactly what I meant.


User 117361 Photo


Ambassador
6,076 posts

So it looks as if your additional page has to point to the css file tucked inside a different folder. Whilst the index just points to the css file inside the css folder (because the index is sitting just outside the css folder), the extra page has to point outside its own folder and then back inside the css folder.
Try this in the additional page head:
<link rel="stylesheet" type="text/css" media="screen" href="../css/main_styles.css"/>


which is really just a shorter way of saying:
<link rel="stylesheet" type="text/css" media="screen" href="http://www.yourwebsite.com/css/main_styles.css"/>


That same top snippet of code should work for any new pages in any of the extra folders you have, providing you don't have folders inside folders which then becomes more complex. But... if you should add a page and just put it in the root folder alongside the index page, you will have to use the css link you used in the index head.
User 563328 Photo


Registered User
85 posts

It was the ../

Thanks so much Janys & tassietiger. You guy's (gals) ROCK!

Kelly
User 117361 Photo


Ambassador
6,076 posts

Great Kelly... pleased we were able to help.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.