Computer problems,Computer help
*AX SOFT>>>Programming & Design

How can I make my PHP document render CSS styles from an external stylesheet?


I'm just starting out with PHP, and already the aggravation starts. When I link to an external stylesheet, the styles don't render. Firefox's error console says that the stylesheet is being served with a MIME type of "text/html", but I have set the type to "text/css". I've done some research, and apparently the PHP parser automatically serves the external file as "text/html".

My problem is, I'm developing on a hosted server, and I have no access to the configuration files. How can I tell my PHP documents to serve the stylesheet with the correct MIME type?

All right, here's the code I'm using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-...
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />

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

<title>Test</title>
</head>



<body>
<?php
echo "<h1>Test</h1>";
?>

</body>

</html>



I think it's pretty straightforward, but like I said, Firefox claims "The stylesheet .../Stylesheets/default_style.css was not loaded because its MIME type, 'text/html' is not 'text/css'."

As you can see above, the MIME is in fact set to "text/css".

<link rel="stylesheet" href="stylesheets.css" type="text/css" media="screen" />

<?php

// php code here

?>

Thats all their is to it. If you're having any problems feel free to contact me if you're still having problems. I don't see why you would be. Were you echoing it in the php code or something?

I used a link to the stylesheet outside of the PHP tags

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

<?php
YOUR PHP CODE HERE
?>

HTH

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • How can i download 3d buildings and 3d airport for free?

    It depends on for what program you want it. Google is marvalous ;) example search: Free 3d studio max models

    ...
  • Can you tell me what is my mistake, and how can i fix it?

    I don't quite see what you are doing with the whole cin bit etc. I'll make you a MUCH improved code ;) float ans; for(float i=1;i<=20;i++){ ans = 1/i; cout << "1/&qu...

  • Could someone please tell me the average salary of Yahoo, Bangalore for a person having 2.5 years or IT exp?

    well if you work for me (pennsylvania) 2 years exp no certifications such as A+ i would pay you around 10.00 a hour so called IT techs are a dime a dozen

    ...
  • Select me good title for my final year project.?

    May be you can search at project assignment website like ...

  • How to code a java picture?

    There are a number of ways to do this. The solution depends on if you're wanting to use AWT, Graphics2D, JFC Swing, or even a non-standard library. The shortest number of code lines would ...

  • I can't edit my freewebs site!?

    Need to know how you are saving it. Are you using the FreeWebs online Visual/Text Editor then clicking the Save icon or are you trying to save your page from your browser via the File, Save Page a...

  • Where i can creat my own web for free? :)?

    Setting up a Web site is very easy and if you want to do it for free just go to ...

  • How can I get the value inside an <option></option> tag on a select box using javascript?

    Use the DOM! :) <script type="text/javascript"> var sel = document.getElementById("MySelectBox") var optVal = sel.options[<position of option, base 0>].text &l...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster