behavior (CSS property)
Example
The following CSS attaches the component file iepngfix.htc to all images in a web page:
img {
behavior: url(iepngfix.htc);
}
Description
Internet Explorer versions 5
and later support the behavior property. The
behavior property lets you use CSS to attach a script
to a specific element in order to implement DHTML (Dynamic HTML)
components.
The script resides in an HTC (HTML Component) file. HTC
files have the extension .htc, and are HTML files that
contain a script plus a set of HTC-specific elements that define the
components.
It’s beyond the scope of this reference to explain the ins and outs of HTC files, but if you visit the Microsoft Developers Network, you’ll find a wealth of information that’ll keep you occupied for hours.
An example of an HTML component, the IE PNG Fix component can be found at TwinHelix Designs. This component implements alpha transparency for PNG images in IE5.5 and 6. It’s the one you’ll find referenced in the example.
Value
The behavior
property requires the URI to the HTC file to be specified using the
url() syntax. Multiple HTC files can be referenced with a
space-delimited list.
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | None |
| 1.5 | None | |
| 2.0 | None | |
| Safari | 1.3 | None |
| 2.0 | None | |
| 3.0 | None | |
| Opera | 9.2 | None |
| 9.5 | None |
This property is a proprietary Microsoft extension to CSS.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

