What is .htc file ?How it works in Internet explorer
It's an HTML Component, a means of encapsulating logic on a web page. Behaviors were described in a 1999 w3 CSS working draft but (as far as I know) only Microsoft provided an implementation in IE 5 and today there are better ways of accomplishing the same tasks.
See also: http://msdn.microsoft.com/en-us/library/ms531018.aspx
HTCs should only be used as a fallback mechanism (which your example demonstrates). Most of what is possible with them is possible using standard, cross-browser CSS and JavaScript in IE 9 and higher.
As to why it works, my guess is that the behavior manipulates IE-specific functionality such as DHTML filters or VML which can be used to achieve visual results that were ahead of their time (though now deprecated).
htc files: Why not to use them?
Quoting Wikipedia:
HTML Components (HTCs) are a
nonstandard mechanism to implement
components in script as Dynamic HTML
(DHTML) "behaviors"[1] in the
Microsoft Internet Explorer web
browser. Such files typically use an
.htc extension.An HTC is typically an HTML file (with
JScript / VBScript) and a set of
elements that define the component.
This helps to organize behavior
encapsulated script modules that can
be attached to parts of a Webpage DOM.
In two paragraphs, the following are mentioned:
- Internet Explorer
- JScript
- VBScript
- nonstandard
I think it's obvious why not everybody is using this technology.
Are Microsoft .htc files a good idea?
If you are going to add CSS3 behaviors to older IE browsers, you really do not have any choice but to use shims like PIE. Whether it is good practice or not really doesn't apply. The question really is, "can I do it?"
I'm currently using PIE for the same reasons you are. It works very well for features that it supports. There is one thing to watch out for. On my site I'm primarily using PIE for rounded corners and gradient backgrounds. Probably 60% of content is generated via templates. So containers holding the generated html can vary greatly in size as dynamic content is being created. PIE doesn't seem to render this situation reliably on IE8 (haven't tested with IE6/7). It works correctly 50 to 90% of time, but I cannot get to 100%. For the pages with static html content, PIE works excellently.
So for a "normal" web page, I'd go with PIE.
In general, for CSS3/HTML5 support, take a look at http://www.modernizr.com/
HTA application, using .htc file. Need to catch HTML-css change event
Thanks Teemu! Using propertychange was the correct solution. But instead of apply this property to body, I must apply it to every tag I need to watch.
I can do it by JS. Thanks again!
<div onpropertychange="alert('changed!')"> </div>
Note : This method won't let you know if the tag's innerHTML changed, only alert if the tag's attribute & css changed. Besides, when the tag is set to "disabled", no event will fire when the tag's css change.
Full references about onpropertychange of IE could be found here :
http://msdn.microsoft.com/en-us/library/ms536956
Will CSS3PIE .htc file load for other browsers even they don't need?
The spec says that browsers are to completely ignore declarations whose property names they don't recognize. This means, theoretically, that since behavior
is an IE-only property, the url()
should not be parsed, and the file not be downloaded by browsers other than IE.
I ran a test on IE9 and Firefox 4, loading the CSS3 PIE tabs demo, and here's what F12 Developer Tools and Firebug show respectively in their network tabs. Notice that Firebug reports no attempt to request the /PIE.htc
file. That means Firefox didn't load the file even though it was declared in your stylesheet, because it doesn't recognize the behavior
property.
IE9 (F12 Developer Tools)
Firefox 4 (Firebug)
The only reason I'd move that property to an IE-only stylesheet with conditional comments is if I don't want to pollute my main stylesheet with non-standard properties and/or hacks.
border-radius in IE not working even though i'm using the .htc file
Take a look at compass which builds off of sass. One of the interesting compass integrations is with PIE.
PIE looks similar to IE-CSS3 http://fetchak.com/ie-css3/ which was previously mentioned.
Related Topics
Why Does an Inline-Block Div Get Positioned Lower When It Has Content
Modal Dialog in Shiny: Can Adjust Width But Not Height
Override Vuetify 2.0 SASS Variable $Heading-Font-Family
How to Inherit Only One Element of CSS Shorthand
Align Material Icon Vertically
Angular 6 - How to Apply External CSS Stylesheet (Leaflet) at Component Level
What Might Cause CSS to Fail to Load Occasionally on All Browsers
Can a Child Div Have a Higher Opacity Than Parent with CSS
Wp_Enqueue_Style and Rel Other Than Stylesheet
CSS3 /CSS - Spinning Background Image
Auto-Contrast Font Color to Background
Absolutely Positioned Flexbox Doesn't Expand to Fit Contents
CSS: :Before: :After Pseudo-Element of Class Not Working
Vscode - Change Highlight Color of Current File
Sass Syntax Highlighting in Visual Studio