How to include php page which include also a css file?

Tags: php,html,css,footer

Problem :

I have searched a lot over stackoverflow and found related answer but those were not perfect solution of this problem. I have a directory named root. Inside the root folder there are 1 folder named footer and 1 file named index.php There are 2 files named footer.php and footer.css in the footer directory. I want to include footer.php file from index.php page. footer.php page has a stylesheet link with footer.css page. But index.php page can not find footer.css page.

Please see code from Pastebin.



Solution :

This will produce horrible html code ... footer.php is a full html page - it has Doctype, html tag, body tag etc. The same goes with index.php. Including footer.php in index.php will produce invalid html file, with html tag inside another html tag (html > body > html > body) ...

The reason why You can't see footer.css it's because it's placed in footer directory. So while you request index.php the proper path to css should be footer/footer.css, and You're getting just footer.css (because path for footer.php is relative).

    CSS Howto..

    How to make a sticky footer using CSS?

    Dropdown Menu doesn't show all links and can't change css social media icons color

    How did overflow actually work here?

    how can bring to front clicked div in jquery?

    How to make only background image transparent in responsive square grid?

    How to use CSS Rotate() in TH Table Tags

    CSS - How to set many div width with a non-round percentage to fill a parent div space

    How to do scale to fit in my case?

    How do I change the alignment of my search box?

    How can i repeat the image rollover and have multiple aligned underneath on my website?

    How to make responsive horizontal grids? [closed]

    How to create e-commerce website [closed]

    With html tables, using CSS, how do I get the tables next to each other?

    How to create equal height columns in pure CSS [duplicate]

    CSS + Show Animated GIF while Loads

    How do I remove the extra height in my
  • ?
  • Flexbox: how to get divs to fill up 100% of the container width without wrapping?

    CSS HTML : stumped on how to center this piece of text

    How do I push inline elements onto the next line

    How Visually Long is a String?

    How do I position this image using CSS so it overlaps a div but displays inline?

    How to show image based on sort type in GridView

    How can i add arrow to image

    How to draw a checkmark / tick using CSS?

    CSS animate — how to fill div from center

    How to align this text in CSS?

    How to enable auto indentation in lists and list items?

    How to display a background image with a:hover

    How can I add a fixed sidebar to a web page?

    In CSS: how to specify the font you want as being BOTH monospace and sans-serif?