Creating a Header/Footer to be Used on all Pages

I referenced this in a post from a few months ago, but never bothered to expound on it. You cannot use cascading style sheets (CSS) to create headers, footers or menus that will be re-used on all of your pages. Instead, you have to use server-side includes (SSI).

There are a handful of ways to use SSI, and they are available in most all of the Web development languages used today. Although I think the use of repeating headers and footers is somewhat outdated, opting more for using templates that dynamically include your content, I’m going to try to teach you a few ways to include your headers, footers and/or menus on all of your pages.

A Simple Introduction to CSS

First of all, to dispel any misinformation that is apparently still going around on the Internet (and, I, too, once believed this when I was first introduced to CSS), CSS is not capable of inserting content into your pages. CSS cannot be used to create headers and/or footers to be used on every page of your site.

For those of you looking for ways to use the same menu on every page of your site, and keep that menu in a single location so that it’s easy to update, CSS won’t do that for you. That’s what server side includes are for, actually. Server side includes can be used with pure HTML (provided that includes are enabled on your server), with PHP, Perl, ASP or basically any other server-side language.

In fact, CSS does almost the opposite. CSS is intended to separate the content from the design within a Web site. CSS is strictly intended to facilitate the “look” of the pages on your Web site. No content is interpreted from CSS.

Now, for the quick lesson on how CSS works.

First of all, we should examine the name. CSS is an abbreviation of the phrase “cascading style sheets”. Let’s pick that apart for a moment.

Cascading
items that overlap, with each new item taking precedence over the previous
Style
refers to the particular look or appearance of a specific item
Sheet
figuratively, this is intended to refer to a collection of items gathered together in a single location, like a sheet of music