Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 09-27-2011, 10:28 PM   #1
Member (8 bit)
 
Join Date: Jun 2010
Posts: 199
Accessing CSS file

Hello folks....

I am trying to figure out how to use code to get the css file location but am having trouble...Let me explain....

here is your folders layout in your public folder

images - dir
css - dir
html - dir

I am trying to access a file (nyy.css) in the css dir.

so the source code would be ./css/nyy.css if the html file was also in the root or public folder but its not....

Ok with me so far....

NOW....lets add another directory but lets call it baseball, within that folder will be another folder called teams then another folder inside that will be nyy.....

images
css
html
baseball -> sports -> nyy

in the nyy folder I have a nyy.html folder.

Here is my question from that html file what is the source code for accessing the css file the css folder in the public folder..

I know its something along the lines of this:

../../../css/nyy.css

I can't seem to get the correct syntax....


Thank You in advance!

Last edited by RobbieG1977; 09-27-2011 at 10:31 PM.
RobbieG1977 is offline   Reply With Quote
Old 09-28-2011, 09:33 AM   #2
I don't computer.
 
mjkovis's Avatar
 
Join Date: Mar 2003
Location: Ellisville, MO
Posts: 1,561
I'm trying to grasp what your question is...

Do you mean you are trying to link a specific document to the CSS stylesheet and you are not sure what the link to that file would be?

For example, below is a sample file structure -

_public_html
__images
__css
___styles.css
__javascript
__folder
___index.html
___subfolder
____index.html
__index.html <- root document when loading domain

So, if you were to link to the 'styles.css' stylesheet from the 'css' folder from the ROOT index.html document you code would be:
HTML Code:
<link href="css/styles.css" rel="stylesheet" type="text/css">
Now, if you were to link to the SAME stylesheet in the 'css' folder from 'folder/index.html' your code would have to change to:
HTML Code:
<link href="../css/styles.css" rel="stylesheet" type="text/css">
Each ../ will take you up one directory level from where the file is you are editing. Therefore, if you were in a subfolder of a folder, to get back to the ROOT directory you would need to use two separate ../ - See example below:
HTML Code:
<link href="../../css/styles.css" rel="stylesheet" type="text/css">
I hope this helps. If you have any other questions, please feel free to ask.

Last edited by mjkovis; 09-28-2011 at 09:44 AM.
mjkovis is offline   Reply With Quote
Old 09-28-2011, 11:55 AM   #3
Member (8 bit)
 
Join Date: Jun 2010
Posts: 199
Hey mjkovis,

That is exactly what I am looking for....

Root Folder
-->css-->month.css
-->images
-->pages
-->Yankees-->schedule-->month.htm
-->index.htm

That is how my root directory is currently setup. Now as you can see I want to take that month.htm and be able to access the month.css file way back in the root dire of the css folder. I know it is along the lines of the html code I have quoted by you. But I still can't figure out the exact line of code.

HTML Code:
<link href="../../css/styles.css" rel="stylesheet" type="text/css">
Thanks!
RobbieG1977 is offline   Reply With Quote
Old 09-28-2011, 12:32 PM   #4
glc
Forum Administrator
Staff
Premium Member
 
glc's Avatar
 
Join Date: May 2000
Location: Joplin MO
Posts: 37,790
Don't take this as gospel, but it looks to me that it would be:

../../css/month.css
glc is online now   Reply With Quote
Old 09-28-2011, 02:46 PM   #5
I don't computer.
 
mjkovis's Avatar
 
Join Date: Mar 2003
Location: Ellisville, MO
Posts: 1,561
Quote:
Originally Posted by RobbieG1977 View Post
But I still can't figure out the exact line of code.
glc is correct below. If your month.htm file is two directories deep it would take two ../ to get back to the ROOT directory.

Quote:
Originally Posted by glc View Post
Don't take this as gospel, but it looks to me that it would be:

../../css/month.css
You actual code below (if an only if it is in that specific directory):
HTML Code:
<link href="../../css/month.css" rel="stylesheet" type="text/css">
OR you can link to it exactly:
HTML Code:
<link href="http://www.example.com/css/month.css" rel="stylesheet" type="text/css">
mjkovis is offline   Reply With Quote
Old 09-29-2011, 09:02 AM   #6
Member (2 bit)
 
Cartin's Avatar
 
Join Date: Sep 2011
Posts: 3
@mjkovis
your advices were very helpfull for me
thank you very much
Cartin is offline   Reply With Quote
Old 10-02-2011, 02:46 PM   #7
Member (8 bit)
 
Join Date: Jun 2010
Posts: 199
awesome..got everything in sync....

@Cartin - glad this thread was very helpful.
RobbieG1977 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:48 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2