WWW FAQs: How are .htm, .html, .asp, .php, etc. different?


2003-07-01: there is no difference between .htm and .html. Early web servers for Unix used .html, while early servers for Windows 3.1 were limited to .htm because of the MSDOS three-character extension limit. Modern web servers are configured to accept both. Web browsers, on the other hand, only pay attention to the "content-type" that the server reports, which will be text/html in either case, and essentially ignore the file extension altogether. Consistency can be helpful simply because commands like:
mv *.html /some/other/directory
will reliably move all of your pages, but that is just a convenience for webmasters. There is no fundamental difference between the two.

The really interesting page extensions are .asp, .shtml, .php, and so on. These are all ways of enhancing a regular HTML page with commands that cause the server to insert files at various points, fetch parts of the page from a database, perform computations and so on. These are known as "dynamic" web pages. The simplest are .shtml files, which feature server side include directives. Almost all web servers support these and they are easy to learn first. .asp files are Active Server Pages, Microsoft's contribution to this category. .php files are PHP pages, which allow pages to be enhanced with the PHP programming language; as of this writing this is a very popular option. Many other .shtml files are HTML containing "server-side include" directives; some servers are configured to only take up the CPU required to parse the pages that have a .shtml extension. .php files, similarly, feature PHP directives. There are many lesser-known dynamic page technologies, most of which have their own commonly used file extension.

Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!