The HTM file format is a web page file written in Hypertext Markup Language (HTML) and uses the .htm extension, which is an alternative to .html. Early operating systems restricted file extensions to three characters, making .htm a common choice, especially in legacy systems.

An HTM file is a plain text file containing HTML code that defines the structure and layout of a webpage. It serves as a blueprint for how browsers display the content, including text, images, multimedia, and hyperlinks. It serves the exact same purpose as an HTML file.
Features of HTM Files
- Text-Based Format: HTM files are simple text files and can be edited with any text or code editor.
- Browser Compatibility: Supported by all major web browsers such as Google Chrome, Mozilla Firefox, Safari, and Microsoft Edge.
- Flexible Usage: Used for static web pages or as a component of dynamic web applications when combined with other technologies like JavaScript.
History of .htm Extension
The .htm extension originated in the early days of computing when operating systems like DOS limited file extensions to three characters. This restriction led to the adoption of .htm as an alternative to .html. Today, modern systems no longer impose this limitation, making .html more widely used. However, .htm extension is still functional and fully supported.
Create and Run .htm file
Step 1: Create a .htm extension file.
You can create a file with .htm extension as similar to .html
Step 2: Open the file
You can choose any code editor like VS Code, Sublime Text etc to open the file and to write code.
<html>
<head>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
h2 {
color: green;
padding: 10px;
text-align: center;
}
div {
max-width: 500px;
box-shadow: 0px 0px 10px 0px grey;
padding: 30px;
border-radius: 10px;
margin: 5rem;
}
p {
margin: 20px;
font-size: 18px;
}
</style>
</head>
<body>
<div>
<h2>Welcome To Geeksforgeeks!!</h2>
<p>
A Computer Science portal for geeks. It contains well written,
well thought and well explained computer science and
programming articles.
</p>
</div>
</body>
</html>
Step 3: Run the file
Double click the index.htm file and your preferred web browser will open and present the content of that page correctly.

Another option is to enter the URL of a .HTM online file in the address bar of your web browser and access the internet web page.
Difference between .htm and .html
| Feature | .htm | .html |
|---|---|---|
| Origin | Used in early systems with a 3-character file extension limit (e.g., DOS). | Became common with modern operating systems that support longer file extensions. |
| Length | 3 characters (.htm) | 4 characters (.html) |
| Default Server Behavior | May not always be recognized as the default index file (e.g, index.htm) | Commonly recognized as the default index file (e.g., index.html). |
| Modern Usage | Less frequently used in modern web development. | Widely used and preferred for modern web development. |
| Compatibility | Fully supported by all browsers and servers. | Fully supported by all browsers and servers. |
| Preference | Often used in legacy systems or for backward compatibility. | The standard choice for web development today. |
| File Size Impact | Slightly smaller extension but negligible difference overall. | Slightly longer extension, commonly used for clarity. |