Legacy Archive (2013): Originally written in Chinese on doubixie.com and translated into English for this edition. All archive posts · Home

What Is .htc?

Original Chinese title: What's .htc

While poking around a Discuz template today, I ran into a .htc file I’d never seen before. Opening it up, I saw what looked like JS functions and definitions alongside some CSS, so I looked it up on Baidu and jotted down a quick note.

From Stack Overflow

What is difference between .htc and .js file?
For Microsoft Internet Explorer 5 and later, HTML Components (HTCs) provide a mechanism to implement components in script as Dynamic HTML (DHTML) behaviors. An HTC is an HTML file that contains script and a set of HTC-specific elements that define the component. The component is saved with an .htc extension. This section lists these HTC-specific elements and the members they support.

In Other Words

1. Introduced in Internet Explorer 5, HTML Components (HTCs) were considered a major breakthrough in Internet Explorer 5.5. Microsoft's goal was to use them to replace ActiveX controls. An HTML Component is an encapsulated object—much like an ActiveX control, it is "self-contained" and can be distributed to anyone once developed. An HTC file isn't just an HTML file with its extension renamed to .htc; it contains scripts along with a set of HTC-specific custom elements.

2. Inside an HTML document, an HTC can be accessed just like any other DHTML element on the page. That means any HTC element can be referenced in script via its id attribute, allowing its properties and methods to be used flexibly through JavaScript.

That Was All Gibberish.

To put it simply, .htc files were just a workaround for dealing with IE—and since the web has largely moved on from IE (and that universally despised IE6), nobody really bothers with them anymore.

Which Explains Why You Rarely See Them.

Over