Welcome to the Treehouse Community
Looking to learn something new?
Stylesheets inside include files?
Hello, is there a way to put all stylesheets and scripts inside one include file and call them on each page?
Seems like regular way of copying style and script links into include file does not work?
Lucas Krause19,924 Points
I think this might help you:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Welcome to my website</title> <?php include("include.php"); ?> </head> <body> <h1>Welcome to my website</h1> <p>My website's content.</p> </body> </html>
<link rel="stylesheet" href="normalize.css"> <link rel="stylesheet" href="main.css"> <script src="main.js"></script>
You can even do something like this inside include.php:
<link rel="stylesheet" href="normalize.css"> <?php $my_stylesheet="main.css"; echo '<link rel="stylesheet" href="'.$my_stylesheet.'">'; ?> <script src="main.js"></script>
Can you show us what you have done so far?