glassfish Posted September 29, 2014 Share Posted September 29, 2014 The root directory: header.php stylesheet.css In the following example I am trying to include the header.php file in a sub folder. When I include the header.php like in the following example then the stylesheet.css file will not work anymore: <?php include("../header.php"); ?> The stylesheet.css file is included in the head tags of the header.php file. Is the above example the right way to do it? If yes, how can I do it so the stylesheet.css file will work too. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted September 29, 2014 Share Posted September 29, 2014 Is the above example the right way to do it? Yes. That path is called a relative file path. This is how you include files from other directories. If yes, how can I do it so the stylesheet.css file will work too. Start your file paths in your HTML with a forward slash (this is know as an absolute file path) eg <link rel="stylesheet" href="/stylesheet.css" /> Quote Link to comment Share on other sites More sharing options...
glassfish Posted September 29, 2014 Author Share Posted September 29, 2014 (edited) When I use a forward slash the stylesheet.css file does not work at all anymore. <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <link rel="stylesheet" type="text/css" href="/stylesheets.css" /> </head> Edited September 29, 2014 by glassfish Quote Link to comment Share on other sites More sharing options...
ginerjm Posted September 29, 2014 Share Posted September 29, 2014 perhaps because you spelled it wrong? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.