Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Why is my Stylesheet Being Ignored in PHP?

Hey guys,

So I'm building a site and I have hit my first hurdle after 10 minutes haha.

I have been developing with PHP for sometime now and I have never come across this issue before and I will try and explain as best I can.

The Problem

So I have my header.php where I declare my stylesheets, which is within a folder entitled inc.

I am trying to link to two stylesheet entitled normalize.css & style.css.

I can successfully see that normalize.css has loaded ok but style.css isn't appear to be loading. I go ahead and do a check in the console to see what's going on but it is completely blank which is highly infuriating.

The Code

I will include all the code I am currently using, thankfully it is short : )

inc/header.php

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title><?php echo $pageTitle; ?></title>

    <link href="css/normalize.css" rel="stylesheet">
    <link href="css/style.css" rel="styleseheet">

    <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
            <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>

        <p>This is the header.php</p>

index.php

<?php
    $pageTitle = "Juicy Tomato";

    include('inc/header.php');
?>

<p>This is the index.php</p>

<?php include('inc/footer.php');

inc/footer.php

        <p>This is the footer.php</p>
    </body>
</html>

I noticed that if I go and view source I can see that the styles within style.css are being loaded and when I make any changes they update ok, it's like as if the browser won't apply them.

I hope that I have made sense, and I know that it is something super simple that I have overlooked and need another set of eyes.

I will appreciate any feedback and advice on how I can get this working and if I manage to get it to work I will obviously add how I went about it.

Thanking you in advance

Stu : )

3 Answers

Paul Johnson
Paul Johnson
18,924 Points

Hi,

Simple spelling mistake(you've typed styleseheet)

<link href="css/style.css" rel="styleseheet">

Change that and it should work.

Hi Stu,

Not sure what the problem could be, whenever I get any front end issues I tend to look at the built in developers tool on google chrome, the console might print a few red lines if there is any related problem such as Failed to load resource, etc... which usually give you a hint of what the problem could it be.

I know it is not very helpful, hope you debug it!

cheers

Thanks Paul Johnson! I don't know how I managed to overlook that!

Stu : )