I was wondering how I could make my footer stick to the bottom of the page, no matter how long the page is. I'd include my footer.php file by using include('footer.php') at the bottom of every page. I have already searched for a good answer but nothing I found works because every tutorial assumes you make your footer on every single page instead of including it. Does anyone know what CSS i'd have to use to be able to do this?
Footer HTML:
<html>
<body>
<footer>This is my footer</footer>
</body>
</html>
Index.php example:
<html>
<head>
<?php
include('nav.php');
?>
</head>
<body>
<p>Blah blah blah</p>
<?php
include('footer.php')
?>
</body>
</html>
Thank you
I think your footer.php file should contain only footer element and its content:
<footer>...</footer>
then add to your css:
footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px; // or any suitable height
display: block;
}
html {
position: relative;
min-height: 100%;
}