HTML - Header and footer

Ask a question
The header on a web page displays the website's name, purpose and/or its logo. The footer on a web page is a place where you can display copyright information or credits for example. It is possible to have a PHP file or a JavaScript-text embedded in the "head" and "foot" of every webpage. Webmasters can use a method to move the common HTML code into separate header.php and footer.php files. Webmasters may manually code or copy and paste the header and footer HTML code from a reliable source into each web page or file. You can use CSS and place it in external files that will improve the web page's loading speed and will also make it easier to maintain and update.

Issue


Is it possible to include a header and footer file using HTML? I have my file (saved as an .html) and need to be able to include the HTML in the header and footer. Does anyone know how I can do this?

Solution



<!-- IE in quirks mode -->        
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">        
<title>Fixed header and footer</title>        
<style type="text/css">        
body{        
margin:0;        
padding:header-<length> 0 footer-<length> 0;        
}        
div#header{        
position:absolute;        
top:0;        
left:0;        
width:100%;        
height:header-<length>;        
}        
div#footer{        
position:absolute;        
bottom:0;        
left:0;        
width:100%;        
height:footer-<length>;        
}        
@media screen{        
body>div#header{        
position:fixed;        
}        
body>div#footer{        
position:fixed;        
}        
}        

  • html body{
overflow:hidden; }
  • html div#content{
height:100%; overflow:auto; } </style> <div id="header"> header </div> <div id="footer"> footer </div> <div id="content"> content </div>

Note


Thanks to abc for this tip on the forum.
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team