Icarus Icarus - 13 days ago 8
CSS Question

Inline css work but external and internal css doesn't work in index.php

As the question suggests I have an index.php file with html in it and when I try to style it using external or internal css, it doesn't work. But inline css works. By the way I am using xampp on win7 to test the website. And the file structure looks like this c:/xampp/htdocs/test/index.php

Relevant html:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width>

<!--<link rel="stylesheet" type="text/css" href="style.css">-->
<!--This css file contains the css shown below as internal css-->

<style>
body{
background-color: blue;
color: white;
}
.header{
color: white;
}
</style>

<?php
function somefuntion(){
/*I will be adding this function later once the html skeleton
is done.
This function will be calculating some numbers based on the
current date and echoing it.*/
}
?>
</head>

<body>
<section class="header">
<p>Spring</p>
</section>
<section class="body">
<p>Hello world</p>
</section>
</body>
</html>


Can someone also explain why internal css is not working?

Solution found by hRdCoder: missing " mark in the content attribute of meta tag.

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

Only things to check for are that you add the closing tag and that the style.css file is in the same directory as your index.php.

Edit:

I just noticed that in your that you're missing the last set of quotation marks (") in the content attribute. Could that be affecting the rest of the page?

Comments