Jump to content

CSS not loading from external stylesheet?


Tenaciousmug

Recommended Posts

Okay the reason I'm doing it this way is because I work locally and then transfer them to the production site.

For some reason, this isn't working even though when I view the page source, it has the right URL, but when it's clicked it goes to a blank page, but when I copy and paste, it goes to the right page.

 

Anywho, this is what I'm trying:

 

<?php $homeURL = 'localhost:90/Elvonica'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Elvonica</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php echo $homeURL; ?>/template/css/skySpirit.css" />

 

I didn't plug in the rest to ignore it since it's not part of the problem. It's printing: localhost:90/Elvonica/template/css/skySpirit.css, but when it's clicked, goes to blank page. When it is copied and pasted, it goes to the right page.

I have a feeling you can't include PHP inside a link rel or any sort of that header information.

If anyone could please help me how to do this, I would appreciate it.

 

FYI:

I did have just template/css/skySpirit.css and it worked until I go into a another directory like forums/index.php. Then it tries to go localhost:90/Elvonica/forums/template/css/skySpirit.css and it's not in there obviously. :P

 

Thank you for anything that you can offer!

I know how to do the includes with the dirname(__FILE__).

Link to comment
Share on other sites

There is no problem with using PHP to dynamically set ANY values in the HTML code - even the href for the style sheet. So, not sure what your problem is, but you don't need to set the value that way. As you found, when using "template/css/skySpirit.css" it will not find the style sheet with opening pages in sub folders. There is a very simple solution. Just put a slash at the beginning of the path and that will search from the root of the site rather than the root fo the current page location.

 

	<link rel="stylesheet" type="text/css" href="/template/css/skySpirit.css" />

 

Link to comment
Share on other sites

Yeah if I put the slash infront of it, it shows this:

 

http://localhost:90/template/css/skySpirit.css

 

It doesn't include my /Elvonica folder that I have the whole solution in. I don't know how to fix that. I know it would probably work on the public server, but not my localhost machine since I have to put the whole project in a solution.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.