XHTML Tutorial: Standards-Based Web Design

by Paul Bohman

File Names

What should you name your files? Does it matter? In some ways, it doesn't matter what your file names are. You can save an HTML document with any kind of strange name if you like, such as 32kjnql.htm. No one will know what that means, but most people don't look at the file name. They just care about the content of the document. Still, you will be doing yourself a favor if you choose names that are easy to remember. For example, if you're creating a document about the products of a company, it might make sense to give it a name like products.htm. This will help you find the file later on.

What about XHTML files? Should you save them with extensions like .xhtm or .xhtml? The answer is that you can, but you'd have to set up your web server to accept this file extension. Most web servers are not configured this way by default. Most people just use the standard .htm or .html extension.

Spaces

Can you put spaces in file names? Yes, but you definitely should not. Some web browsers and/or servers have a hard time with file names that have spaces. You can always use an underscore or a dash when writing long file names. You can even run all of the words together.

Acceptable (Good) File Names: soap_products.htm, soap-products.htm, soapproducts.htm

Problematic (Bad) File Name: soap products.htm

File Extensions

File extensions are added on to the end of the file name. Common file extensions (for various types of documents) are .htm, .html, .doc, .ppt, .pdf, and others. The file extension helps the web server know what kind of file it is. If the file extension is .htm or .html, the web server knows that it is an HTML (or XHTML) document. If the file extension is .doc, the web server knows it is a Word document.

When saving files as HTML (or XHTML), you have to give them either the .htm or .html extension at the end, such as index.htm or index.html. Either one will work. It really doesn't matter which extension you use, but it is a good idea to be consistent. If you use .htm on one file, use .htm on all of the files.

Note: If you are developing dynamic web pages using technologies such as PHP, JSP, ASP, Cold Fusion, etc., your file extension must match the technology in most cases. For example, you would save a file as index.php (or index.jsp, or index.asp, or index.cfm) instead of index.htm.

Do you have to save all of your documents with file extensions? Yes.

When creating links, you should include the file extension (unless the web server has been set to accept links without file extensions—but for our purposes, I'll just say that it's a good habit to always include the file extension).

Note: Modern operating systems (like Mac OSX and Windows XP) often hide the file extension from you unless you have set the operating system preferences to make the file extension visible. This is not a problem as long as you know what the file extension is. For HTML/XHTML files it is normally either .htm or .html. The file extension always shows up in Dreamweaver, no matter what your operating system preferences are.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.