behavior (CSS property)

Spec
Inherited Initial Version
No CSSN/A
Browser support (more…)
IE5.5+ FF3.5 SA4 OP10 CH2
Full None None None None

Syntax

behavior:URI;

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. Internet Explorer Version 8 supports the syntactically correct Vendor Specific Extension format of-ms-behavior.

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.

Example

The following CSS attaches the component file iepngfix.htc to all images in a web page:

img {
  behavior: url(iepngfix.htc);
}

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

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full None None None None None None None None None None None None None

This property is a proprietary Microsoft extension to CSS.

User-contributed notes

There are no comments yet.

Related Products