Save Time with Include Files

How much time do you spend typing (or even just cutting and pasting) the same HTML (or PHP, etc) into blank files? What if there was a simple way to put the same HTML on every page without having to retype it all every single time? Well, there is! It's called using include files, and it's not just for programmers. Taking the following HTML page as an example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
   <head>
      <meta name=.../>
      <script type="text/javascript" src=.../>
      <link rel="stylesheet" type="text/css" href=.../>
      etc., etc., etc., 
   </head>
   <body>
      <div class="navMenu">
         <ul class="nav">
            <li><a>Nav Item 1</a></li>
            <li><a>Nav Item 2</a></li>
            <li><a>Nav Item n</a></li>
         </ul>
      </div>
      <div class="content">
         <p>Here is your content.</p>
         <p>Way down here, toward the bottom of your file.</p>
      </div>
      <div class="footer">
         <div class="footerNav">Perhaps another nav menu goes here, in the footer.</div>
         <div class="copyright">©2011. This is on every page, of course.</div>
      </div>
   </body>
</html>

Had we used include files, the above page would look more like this:

<!--#include file="head.shtml"-->
<!--#include file="nav.shtml"-->
<div class="content">
      <p>Here is your content.</p>
      <p>It's not so hard to find now.</p>
</div>
<!--#include file="footer.shtml"-->

In this example, the HTML is exactly the same; it is just broken up into four short files instead of one long one. In this way, you can make as many pages as you need and, assuming they have the same layout, nav, etc., you would only need to change the content on each page. Now, isn't that much cleaner? ASP.NET can be included in the same way and PHP includes work like so: <?php include("header.php"); ?>.

Using an include file for your navigation? Use this plugin to highlight the current page.