This page is also one directory deeper into the site in the subfolder. It pulls in the header/footer from one directory up. However, this page pulls in a different header named header2.php. That header file is identical to the original header.php file except for one thing. It uses the HTML base element to set a "base URL" for all the content the header needs to use. Look at the code in header2.php for some explanation.

So what's the moral of this story? That you should use two different header files like this example? NO! C'mon, man. That defeats the whole purpose of having a common header/footer for uniformity accross your site.

The moral of this story is the following. If you need to use the common header/footer for content deeper into your site in a subfolder, then you need to use the HTML base element to set the context (base URL) for all the resources that your header/footer is to use.



NOTE: There is one small drawback the astute reader might notice. We have repetitively heard that one shouldn't use absolute URLs internally within your site. Because then your site is not portable. The pages and resources only need to know where they are relative to each other, not ambient information like the address of the server. If you move your site to a different location, the absolute URL's will no longer be accurate.

Notice that everything in this example is still done with relative URL's. The only absolute URL is in the HTML base element. If one needed to move this example (change root folder name or move to different server), only that base URL would need to be changed. No big deal. That is a small price to pay for being able to use a common header/footer for content deeper into your site. It is quite common for a site to be completely portable (relative internal linking) except for one or two configuration values such as this base URL.