Naming Conventions

Eventually, your HTML pages and all accompanying resources (pictures, sounds, animations, etc) will be served over the World Wide Web via a special web server. A web server is a computer with a large hard disk that is run by software which permits web browsers (such as Internet Explorer and Netscape Communicator) to download HTML pages and other resources; as a web developer, you will probably be uploading your HTML pages and resources to one of these web servers using FTP (file transfer protocol) software via the Internet.

Web servers, and the Internet at large, follow UNIX-based naming conventions for files; many characters are restricted and therefore not permitted as a part of a file name. In addition, Windows-based and DOS-based machines, which many of you use for web development, have additional restrictions on file name syntax. Names are not restricted to file names only, either; you will find names in many places in HTML, as well as in JavaScript, other programming languages, and multimedia animation and development environments like Flash and Director/Shockwave.

To support every platform, technology, and circumstance associated with the Web reliably, the following naming conventions must be observed:

  2. Use only numbers (0-9), the 26 lower-case letters (a-z), the 26 upper-case letters (A-Z), and the underscore (_) character to create your names.
  3. The period/dot (.) character may be used in file names ONLY, to create the extension name for a file (i.e. myFile.html). The period should never be used for any other purpose in a name.
  4. Always begin your name with a letter, preferably a lower-case letter; numbers and the underscore character may appear anywhere in the name after the first letter.

These are general-purpose naming conventions, not just for the Web and HTML, but for creating names in any programming language, on any platform. If you memorize these few rules, you will not encounter technical difficulties caused by bad naming practices.

Of course, there are exceptions to some of these rules in each specific environment; you have probably already run into a few examples. If YOU follow these rules, however, you will never have any difficulties ANYWHERE.

Internal Capitalization

Any combination of uppercase and lowercase letters and numbers can be used in a name. However, there is a standardized convention regarding the use of lowercase and uppercase letters in names, a convention which has been officially decreed in the standards published by the World Wide Web Consortium (the international standards body for the Web, at This convention is called internal capitalization, and has been used in traditional programming for many years.

Internal capitalization states that all letters in a name be lowercase, except where two words conjoin, wherein the first letter of the second word becomes capitalized.

If I wanted to name an HTML file using the phrase "My Cat Page", then, I would name it "myCatPage.html" or "myCatPage.htm". Instead of placing a space between words, I simply capitalize the first letter of each word at the conjunction point; again, the first letter of the name is always lowercase, as are all of the remaining letters beyond those under discussion.

More example HTML file names:


This convention, along with the rules above, would also be used for other sorts of names, from variable and function names in JavaScript, to NAME attributes in HTML, to TARGET names in HTML, etc. We'll discuss these and other names in later modules.

Discussion of the Naming Rules

Rule One:

I want to emphasize the importance of Rule Number One, "NO SPACES IN THE NAMES"; this rule is so important, that I've repeated it as Rule Number Five. For some reason, this rule is the one that students seem to have the most difficulty remembering. I emphasize this rule so often in my classes that it has become my nickname at the MSP: "Mr. No-Spaces-In-The-Names" (that's me!). I have even been driven to create a line of souvenir memorabilia products with this rule printed on them; you can check them out via my website,

I think that the reason that students have trouble remembering this rule is that both the Macintosh and Windows operating systems ACCEPT spaces in file names. In addition, when resources (such as digital images, other HTML pages, or animations) are called from an HTML page residing on a LOCAL hard drive or Zip drive or floppy drive on their own computer, files with spaces in the names deliver properly. The problem is that, once students post their pages and other resources onto the Internet, or begin programming in any programming language, they rapidly discover that nothing works at all, and they can never seem to understand why! It's because THERE ARE SPACES IN THE NAMES! Names may NOT have spaces in them!

Rule Two:

The use of special characters in names is very dangerous. Some characters, such as the hypen or minus-sign (-), are permissible in one place and completely illegal in all others. Most characters, including tilde (~), the question mark (?), the at symbol (@), and many others, have reserved meanings or usages which preclude their use in names.

If you stick to letters, numbers, and the underscore character, you'll be safe when creating names under all circumstances.

Rule Three:

Only use the period/dot (.) character to indicate the dot-extension for a file name. In programming languages in general, the dot (.) character is reserved for specific purposes, and is forbidden in names. Even though web servers can support extra dot characters in a file name, those illegal file names will cause other technologies interacting with your HTML page to malfunction.

Rule Four:

Always start all names with a letter, preferably lowercase. No programming language can tolerate names with a number as the first letter, and the underscore as the first letter of a name is a reserved usage.

Rule Five:

To close, remember: NO SPACES IN THE NAMES

(If I had a penny for every student who thought that he or she could get around this rule, I would be a millionnaire and could retire to Hawaii to bask on black sand beaches with a tropical drink in my hand...)

Main Menu