How to make css to work in subdomain?

  • George L.
  • Bronze Member
  • Bronze Member
  • George L.
  • Posts: 2209
  • Loc: Malaysia

Post 3+ Months Ago

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.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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.
  • George L.
  • Bronze Member
  • Bronze Member
  • George L.
  • Posts: 2209
  • Loc: Malaysia

Post 3+ Months Ago

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
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

start from the beginning, what have you done so far ?
  • George L.
  • Bronze Member
  • Bronze Member
  • George L.
  • Posts: 2209
  • Loc: Malaysia

Post 3+ Months Ago

Hi Joe,

The style.css can not link to my .php page.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5148
  • Loc: SC-USA

Post 3+ Months Ago

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.
  • George L.
  • Bronze Member
  • Bronze Member
  • George L.
  • Posts: 2209
  • Loc: Malaysia

Post 3+ Months Ago

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
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 21 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.