2

I am trying to implement a Sample MVC(PHP) in which CSS file doesn't seem to be working . i Suspect it could be my referring style . The below code is of header from views

Views-> header.php

<!doctype html>
<html>
<head>
        <link rel="stylesheet" type="text/css" src="public/css/default.css">

</head>
<body >
    <div id="header">Header</div>
    <div id="content">
    <p>dsfds</p>

css file Public/CSS/Default.css

body {
    background: silver;
}

For clear picture this is my folder structure

Folder Structure

Arun3x3
  • 193
  • 1
  • 7
  • 17
  • Try ../public/css/default.css – Adam Aug 24 '16 at 18:13
  • There is an htaccess which may have rewrite rules so url can be different from your structure. I will prefer you to use absolute url insted of relative. This will work for you. – Aman Rawat Aug 24 '16 at 18:22
  • @aman rawat Indeed it was .htacess at the end that was causing issues. Apparently file was being detected with issue "Resource interpreted as Stylesheet but transferred with MIME type text/html:" had to rewrite htaccess that fixed the issue. – Arun3x3 Aug 24 '16 at 19:09
  • Solution for this issue was found in the below link http://stackoverflow.com/questions/22631158/resource-interpreted-as-stylesheet-but-transferred-with-mime-type-text-html-see by using the code from this source .http://pastebin.com/w8UnqFs8 – Arun3x3 Aug 24 '16 at 19:28

3 Answers3

0

Have you tried:

<!doctype html>
<html>
<head>
        <link rel="stylesheet" type="text/css"   href="../public/css/default.css">
</head>
...
boroboris
  • 1,548
  • 1
  • 19
  • 32
0

Your code is starting at header.php and now looking for /public/css/default.css.

In this case you would need your file to be in views/public/css/default.css

Try changing your code to

<!doctype html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../public/css/default.css">

</head>
<body >
    <div id="header">Header</div>
    <div id="content">
    <p>dsfds</p>

by adding the .. prior to the location of the file it tells it that it needs to take one step back (putting you in the root directory) and than to look for /public/css/default.css

Edit: Make sure you're switching src = " " to href = " ".

Adam
  • 518
  • 2
  • 19
0

The path should be from the index file not from the header. the header.php is just like copy and paste text into the index.php

use

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

or

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

depending on which index.php file you are at, the one inside the views folder or the one on the sourceFiles folder.

Hope this helps.

Running Buffalo
  • 1,243
  • 2
  • 9
  • 17