Css...

Vetch

Registered
I've been making websites for a number of years now, however, I just can't seem to get CSS to work when running my Mac.

The problem is as follows:

I'm writing a database driven website using PHP and MySQL, everything was going well until I tried to include an external CSS file to allow me to change fonts/rollovers/everything else people do with CSS with ease. However, it's not workingg. The weird thing is that when I'm running the site from my server PC users can log into the site and see the CSS working fine... So frustrating!

Anyway, here follows two lines of code, the first from the HTMl document, that includes the CSS, and the second from the CSS itself.

If anyone can find any errors in either of the lines of code that could make the CSS not work (on both Safari and IE under Mac OS X.2.3 (no time to upgrade damnit!)) then I would appriciate it, otherwise if there is a known way to fix CSS then that'll help too.

HTML/PHP:

<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"css/styles.css\">

CSS:

ltext { color: #040D52; font-size: 8pt }

Thanks muchly in advance,

Vetch
 
Hmm, I have CSS working with apache on my machine. I don't really host a site, just do small tests with it, but it works. Though I haven't tried it with PHP...maybe I'll try a little later and see if that makes any sort of difference. It shouldn't, but you never know.
 
If you are calling it by class="ltext" then in the style sheet it should be called .ltext

Good catch, Twister!

I'm a heavy user of CSS in all my sites and have had no problems in any of the browsers (except for the minor hiccups in Safari that are not surprising for a beta).

If your prob is not as Twister predicted, what does the <link> tag look like after it is processed by php and sent to the browser? (use view source)

bear
 
Okay, the lack of .ltext was a typo - the actual thing does have the full-stop (sorry for being so british ;) ) and the view source looks like:

<LINK REL="stylesheet" TYPE="text/css" HREF="css/styles.css">

Unsurprisingly :)

Keep the ideas coming! :)
 
Can you show us the actual css and file? It'd be easier to see what's happening.

Also, while were on the CSS topic. Can i have multiple styles for a link? I want some links underlined, some not. Things like that? I tried the other day but I think i was doing something wrong. Do i not create any style for A:Link and just put all that style in a .LinkUnderline?

Does that make since?
 
You can simply write:
.anyname { style characteristics }

then for your link write:
<a.anyname href="url">text</a>

Source of info: my mate ASH. :)
 
I can't exactly print two files here. If you give me your e-mail address though I'll send it to you - unless you have MSN in which case we can meet on there and I'll give you my IP so you can see it running from my server.

Cheers.
 
I tested out a PHP with CSS...worked fine. Are you sure there aren't any errors in the stylesheet you're linking in?
 
Feel free to email me or pm me. You can do that by clicking the profile button at the bottom of this post
 
Darkshadow: Positive there are no errors. I've coded PHP and CSS together before, which is why I don't think it's actually a problem with the code. I'm wondering if there is a way that CSS is messed up on my computer, or if I have to do something to turn it on (which I serverly doubt)...

Especially since the code worked fine on my friends PC when he visited the website (see original post)...

Any ideas about system configs that I need to change? :)
 
New question. Is this <LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"css/styles.css\"> inside the php <? ?> tags? If not then you should just have <LINK REL="stylesheet" TYPE="text/css" HREF="css/styles.css">
 
example....

<html>
<head>
<title> <? $pageName ?> </title>
<LINK REL="stylesheet" TYPE="text/css" HREF="css/styles.css">
</head>

<body>

<?

$content;
echo ("all php code goes in this area");

?>

</body>
</html>

-----end example ---
this was written off the top of my head. not checked for errors.
 
Tried that. Didn't work. I even just created a .html file this afternoon and tried to get CSS working on that, with no success.

I'm now assuming that it's my computer, not the code!
 
How odd. Can you post or send me your sample files that you tried to get working? It should work on your computer... even if it's not online. One thing you have to do, is load the external CSS file every time you change it if it's on your HD, or else the changes are not reflected in your page.

Try this. Create a new file, and type (or copy):
Code:
<html>
<head>
<title>Sample Page</title>

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

</head
<body>
<span>This is a sample span.</span>
</body>
</html>
Save this file somewhere as "sample.html". Now, create a new file and type/copy the following:
Code:
span {font-size: 18px;
 font-family: courier;
 color: red}
Save this as "sample.css" in the same directory as sample.html, and fire it up in your browser of choice (or other browsers... be sure that the problem isn't just your browser!). Then give us the results.
 
Hmm, are you using the same web browser you were before? Or, did you turn off CSS rendering in the browser at some point and then forget to turn it back on? It could be that.
 
Problem solved!

I think something odd happened to the files (God only knows what) but I got annoyed last night and remade both the .css and the .php files from scratch without copying/pasting anything, and it worked first time. Corrupt files or something? This would probably also explain why it worked on a PC and not a Mac or Linux - PCs are corrupt anyway, so it didn't matter running messed up files..

Well, there's another problem sorted... Thanks all for help!
 
Back
Top