home about us contact us

free scripts advanced scripts online tools great books web related tutorials contributed tutorials news archive geek toys!

help forum live chat help

HTML File Names - a few simple rules to make life simple down the road

HTML Files should have simple straight-forward names. Seems easy enough, but if you aren't careful, you can make a few missteps without intending to. This is one of the most common problems to plague and frustrate the beginning coder of HTML.

Use HTML Extension Unless You Can Explain Why Not:

HTML files are what? HTML! So when you name them, use the extension (or part that comes after the period) ".html" with certainty and regularity. In the days of Windows 3.1, the three must have stood for three character extensions, so you were limited to .htm for example. Those days are gone, get over it, and use the four character extension.

There are some noteable exceptions to the .html extension rule that, unless they mean something to you now, should be avoided. These are special names which usually create an effect on the server. Most typical examples are .php, .asp, .shtml, or .cfm. What those do -- if you really care just now -- is cause the server to look for hidden code in the pages. Unless you hid some code that the server can understand, it simply adds additional work for the server and causes your reader to wait while the server does that. The delay is really momentary for the one page, but on a server with many pages being called, it can really add to its load. As you grow in your skill level later, you will learn about and begin to use some of these fancy extensions, perhaps.

The Name: call it what it is!

For most files the best thing to do is call it what it is. If it is your page about your brother, for example, call it brother.html. If it is about your sister, call it sister.html. If you have more than one brother, call it brotherbob.html and brothersam.html if they happen to be named Bob and Sam. Don't call it pageone.html, pagetwo.html, etc. because when someday you wish to make changes, you need to look at an index to find the page about your brother Bob.

Everything Is lowercase, NO UPPERCASE:

For people on a Windows computer, they can create file names willy nilly without regard to UPPER or lower case. They can still view their pages and see them fine on their machine, and links to the pages will work fine regardless of the case. The problem is that most people will be loading their pages onto a Unix or other similiar server that cares deeply about case. Thus, brotherbob.html, BrotherBob.html and BrotherBob.HTML are three different files on the server. Links that worked on your local machine will no longer work on the server.

Some people -- and we ain't them people (even though we broke the rule for this page because we use the file name to generate the tutorial index) -- say go ahead and use capitals, BrotherBob.html is easier to read than brotherbob.html. However if you undertake this scheme in the interest of readability, you will necessarily have troubles later because you forgot to match capitalization. Better to always follow this rule: always always always and without fail use lower case for file names. It is that simple, don't capitalize and you won't forget to match case for a link.

Use the Underscore for Readability

For those occaisions where you really must have readability, use the underscore to separate words: brother_bob.html I know, you can forget to match that too, but not if you always separate words with an underscore. Get a consistent pattern and follow it. But best if you just skip it, you'll be able to figure it out without them.

Never Use Any *^%*#@ Characters

Those are fine for Beatle Bailey and Sarge, but leave out any characters in filenames except for a-z and 0-9. Don't use a space -- and I mean ever! Spaces don't interpret right in some browsers. Don't use any character except those thirty-six.

There is One Special First File:

One special file, the first file in each directory should be called something special. It varies from server to server, but usually it is called index.html, home.html, or default.html. Whatever is in that file is displayed when you go to the main directory of and if it isn't specified you either see a complete directory of files, or you see an error message saying you don't have access. Try one of these three names, and odds are you will see the page by that name displayed when you go to the directory. If none of those work, then try the same three with the three character extension .htm: index.htm, home.htm, or default.htm. If none of those work, click your heels three time and repeat, there's no place like home while contacting your server host.

The rules aren't tough, but they are important. Follow them and you will have a more pleasant learning process.

So if you are ready to learn more ...
Back to the Tutorial Index