Skip to: content, navigation

behavior (CSS property)

Browser support full matrix
IE5.5+ FF2 Saf3 Op9.5
Full None None None
Spec
Inherited Initial Version
No CSSN/A

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

IE5.5Full
6.0Full
7.0Full
Firefox1.0None
1.5None
2.0None
Safari1.3None
2.0None
3.0None
Opera9.2None
9.5None

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.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters