Hi I’m making a website and one of the things I want to do is use ‘include/header’ on my content pages. The site is using php and uses a login system. The header is made with css, and when I try to include it in a page in a different directory the header seems to break from its link to its css. I have two questions: 1 How do I resolve this problem? 2 Is it still goog practice it include the header? If not, what else could I do? Many thanks in advance
make sure the relative paths are correct and its obviously a good practice to have a separate header file.This way you can change them easily whenever needed. Thanks
Hi ssmm987 and ankit Thanks for your input. I have my header in the root directory. I want to include in the sub-directory of another directory. When I do this, the header link to its css file is broken because it is being called from a different location. ssmm987, I have read about ‘mod rewrite’. I’m not sure this will help this problem. I think the link is breaking because its being called from a ‘new’ location. How can I resolve this as I want to only use one header and its css file? Thanks again
Try using href="./directory/style.css" Code (markup): or don't forget you can always use the full url href="http://domain.com/directory/directory/style.css" Code (markup):
If you have the header added to your index.php page and that links to the css file, but then add the header to say products.php it will not keep the css unless you have the css file linked to in the products.php page also. Also use the full URL to make sure that isn't an issue either. If you already have the css linked to each page your adding the header to, then why not just put the header styling into the header file that you are including. That way it will always be with the header. Sorry if that isn't clear enough, but all of those solutions should work for you.