html - Choose unique stylesheet for a single page with php


My question is: is it possible to have different stylesheets on the same website? I’m already aware that its possible to link several stylesheets to each other but that isn’t quite what I’m looking for. My goal is to make it possible for a logged in administrator to edit a stylesheet that only affects the look of the start page.

The website uses php for connecting the pages to one another and the links to the stylesheets are located in theheader.php document:

<?php if(isset($_SESSION['stylesheet'])): ?>

<link rel="stylesheet" href="style/<?php echo $_SESSION['stylesheet']; ?>"> 

<?php else: ?>

<link rel="stylesheet" href="style/stylesheet.css" title="General stylesheet">

<?php endif; ?>

Would it be possible to modify this code so that an alternative stylesheet controls the look of the front page exclusively?




According to your comment that the start page has a variable$pageId with the valuehem you can include a stylesheet exclusively to the start page by adding

if($pageId == "hem") {
    echo '<link rel="stylesheet" href="path/to/stylesheet/for/startpage.css">';

People are also looking for solutions to the problem: php - Triming a paragraph


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.