Common File Types and File Extensions

What Do All Those File Types Mean?

Files and Laptops
Willie B. Thomas/Getty Images

When learning what it takes to build a web page, you'll come across many different types of files. Even though most web pages are run on Unix web servers which, like Macs, don't require file extensions, filename extensions are the most common way to differentiate between files. Once you see a file name and extension, you know what type of file that is, how the web server uses it, and how you can access it.

The Common File Types

The most common files on web servers are:

  • web pages
  • images
  • scripts
  • programs

Web Pages

There are two extensions that are standard for web pages:


There is no difference between these two extensions, you can use either on most web servers.

.html was the original extension for HTML pages on Unix web hosting machines. It references any file that is HTML (or XHTML).

.htm was created by Windows/DOS because of it's requirement for 3 character file extensions. It also references HTML (and XHTML) files, and can be used on any web server, regardless of operating system.

index.htm and index.html
This is the default page in a directory on most web servers. If you want someone to go to your web page, but you don't want them to have to type a file name, you should name the first page index.html. For example will go to the same place as

Some web servers call this page "default.htm" and you can change the filename if you have access to the server configuration. Learn more about index.html pages

Most web browsers can accommodate 2 types of web images directly in the browser, and the third type (PNG) is gaining a lot more support. Note, there are other image formats that some browsers support, but these three types are the most common.

The GIF file is and image format that was first developed by CompuServe. It is best used for images with flat colors. It offers the ability to “index” colors on your images to make sure that they contain only web safe colors or a small palette of colors and (with flat colored images) make the images smaller.

You can also create animated images using GIF files.

The JPG or JPEG file format was created for photographic images. If an image has photographic qualities, without expanses of flat color, it is well suited to being a jpg file. Photographs that are saved as JPG files will generally be smaller than the same file saved in a GIF format.

The PNG or Portable Network Graphic is a graphic file format that was made for the web. It has better compression, color, and transparency than GIF files. PNG files don’t necessarily have to have the .png extension, but that's how you'll most often see them.

When to Use the JPG, GIF, or PNG Formats for Your Web Images

Scripts are files that activate dynamic actions on websites. There are many types of scripts. These are just a few that are fairly comon on websites.

CGI stands for Common Gateway Interface. A .cgi file is a file that will run on the web server and interact with the web user. CGI files can be written with many different programming languages, like Perl, C, Tcl, and others. A CGI file does not have to have the .cgi extension, you might also see them in /cgi-bin directories on websites.

This extension indicates a Perl file. Many web servers will run a .pl file as a CGI.

A .js file is a JavaScript file. You can load your JavaScript files into the web page itself, or you can write JavaScript and place it in an external file and load it from there. If you write your JavaScript into the web page you won't see the .js extension, as it will be part of the HTML file.

.java or .class
Java is a completely different programming language from JavaScript. And these two extensions are often associated with Java programs. While you probably won't come across a .java or .class file on a web page, these files are often used to generate Java applets for web pages.

On the next page you’ll learn about server-side scripts that are very common on web pages.

There are also some other file types that you might see on a web server. These files are usually to give you more power and flexibility on your website.

.php and .php3
The .php extension is nearly as popular as .html or .htm on web pages. This extension indicates a PHP page. PHP is a web scripting program that brings scripting, macros, and includes to your website.

.shtm and .shtml
The .shtml extension indicates an HTML file that should be viewed with the SSI interpreter.

SSI stands for Server Side Includes. These allow you to include one web page inside another, and add macro-like actions to your websites.

A .asp file indicates that the web page is an Active Server Page. ASP provides scripting, macros, and include files to a website. It also provides database connectivity and much more. It is most often found on Windows web servers.

.cfm and .cfml
These file types indicate that the file is a ColdFusion file. ColdFusion is a powerful server-side content management tool that brings macros, scripting, and more to your web pages.