How to make css to work in subdomain?

  • George L.
  • Bronze Member
  • Bronze Member
  • No Avatar
  • Joined: Nov 05, 2007
  • Posts: 2206
  • Loc: Malaysia
  • Status: Offline

Post November 20th, 2008, 3:28 am

Hello,

Do I need to put the CSS files inside the subdomain folder?. How do I change this link?

Code: [ Select ]
<link rel="stylesheet" type="text/css" href="style.css" />

I am not sure. Thank you very much.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 20th, 2008, 3:28 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post November 20th, 2008, 4:24 am

Yes, the resources need to be in the subdomain folder relative to the page that's loading them.
You shouldn't need to change that link.

Unless you're talking about setting up another subdomain that two domains can draw resources from, they your link will look something like this
Code: [ Select ]
<link rel="stylesheet" type="text/css" href="http://style.domain.com/style.css" />


and you will place a single copy of each style element in the folder that "style" subdomain points to. Doing it this way has an added benefit of allowing browsers to load the resources only once for multiple subdomains in addition to you only needing to maintain a single copy of each file across domains.
Strong with this one, the sudo is.
  • George L.
  • Bronze Member
  • Bronze Member
  • No Avatar
  • Joined: Nov 05, 2007
  • Posts: 2206
  • Loc: Malaysia
  • Status: Offline

Post November 20th, 2008, 5:34 am

joebert wrote:
Yes, the resources need to be in the subdomain folder relative to the page that's loading them.
You shouldn't need to change that link.


Hi Joe, thank you for your help. Unfortunately, that was what I did but to no avail. I wonder what is wrong. Could it be the root is in public_html?

Thank you for your reply.
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post November 20th, 2008, 6:15 am

start from the beginning, what have you done so far ?
Strong with this one, the sudo is.
  • George L.
  • Bronze Member
  • Bronze Member
  • No Avatar
  • Joined: Nov 05, 2007
  • Posts: 2206
  • Loc: Malaysia
  • Status: Offline

Post November 20th, 2008, 6:56 am

Hi Joe,

The style.css can not link to my .php page.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post November 20th, 2008, 7:08 am

George,
Wherever you're PHP or HTML file resides is the relative starting point. So, the reference in the <link> tag should start from there.

If your style is in the same directory the "href" attribute is "style.css".

Code: [ Select ]
<link rel="stylesheet" type="text/css" href="style.css" />


If your style is in the directory within that starting point the "href" attribute is "folder/style.css".

Code: [ Select ]
<link rel="stylesheet" type="text/css" href="folder/style.css" />


If your style is in the directory before that starting point the "href" attribute is "../style.css".

Code: [ Select ]
<link rel="stylesheet" type="text/css" href="../style.css" />


You can also use an absolute address as joebert demonstrated above.

Code: [ Select ]
<link rel="stylesheet" type="text/css" href="http://www.website.com/folder/style.css" />


If none of these methods are working for you, then there is an error in what you've written.

Maybe you should just post the entire <head> of your document.
- dM
  • George L.
  • Bronze Member
  • Bronze Member
  • No Avatar
  • Joined: Nov 05, 2007
  • Posts: 2206
  • Loc: Malaysia
  • Status: Offline

Post November 20th, 2008, 8:08 am

Hi dM, Joe, Thank you so much for your help. I hope I can say it is working now. But not tonight. I am going to sleep now. I have read your explanation numerous time. It is worth reading. Thank you again.
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post November 20th, 2008, 8:11 am

Sleep helps.

I take a nap in the middle of the afternoon if something starts taking me awhile to figure out, then when I wake up it's always simple and rather than me being frustrated trying to figure it out, whoever I'm working with is frustrated that I'm sleeping instead. Either way it gest done in the same amount of time.
Strong with this one, the sudo is.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 83 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.