Search code examples
phphtmlcssstylesheetexternal

External stylesheet (css) in php


I have looked through 4-5 post on stackoverflow regarding this without solving my problem.

I have a php file and want to use the css stylesheet I have for the other HTML files.

Right now it looks like this:

 <div style="height: 600px;">
      <?php
       echo "<link rel='stylesheet' type='text/css' href='stylesheet.css' media='all'/>";
       session_start();
       $admin = $_SESSION['admin'];
       $author = $_SESSION['author'];
       ?>
       <?php if ($admin == true AND $author == true) { ?>
           <p id="confirmationText"><?echo "Thank you for your message! <br>You should have received a confirmation email. We will contact you soon."; ?></p>
       <?php } ?>
</div>

It is not working; the p id="confirmationText" text does not get formatted. interestingly, when I just open the file locally without apache server, it will get HTML-formatted.

What to do?


Solution

  • Can you open the stylesheet in your browser?

    Also, why are you echoing a stylesheet in a div, and not in the head?