CSS BEHAVIOR
The Behavior property specifies one or more space separated URLs indicating script(s) to attach to a CSS selector. Behaviors allow the default functionality of a given element to be extended. Using simple CSS syntax that allows script to be separated from style and content, CSS behaviors offer a fairly elegant and efficient way to re-use script code.
Example
| blockquote { behavior: url(hilight.htc) url(#behaveBinObject) }
<blockquote style=”behavior: url(hilight.htc) url(#behaveBinObject)”>Some text</blockquote> |
Possible Values
| Value | Description |
|---|---|
| [Script URL] | Provides an absolute or relative URL reference to the Behavior. |
| [#Object ID] | The Behavior is a binary implementation. This syntax consists of a pound sign (”#”) followed by an OBJECT element ID within the document that instantiates the binary implementation. |
| [Default Behavior] | Quite a few default behaviors ship with Internet Explorer 5.0. This syntax allows each default behavior to be easily referenced. |




Hey,
I found this page. I’d like to get the best book on CSS on the market. Something that covers it all. I have yet to find a book that does. Can you help me?
Jim.
nice post. i like that…
How can i use it. and when should i use it?
Hello,
Are there any working example of this property so that we can actually see it implementation in realtime.
hi
How can i use it. and when should i use it?
where is hilight.htc file
The most commonly used scripts that I’ve seen deal with hacking IE. Either making transparent PNGs display correctly or tricking IE into maintaining a :hover on elements it doesn’t like to.
This would be a difficult property to provide specific examples of that would be relevant to it’s usage.
This is an IE specific CSS property. Use it only when you want to fix something in IE, Otherwise i think you shouldn’t. An excellent example of this is IEPngFix.
The CSS behavior property only works in Microsoft. It doesn’t separate style from content any more than any other CSS property, but it sure does introduce the rather abusive idea of connecting style to script.
The CSS behavior property is basically, you want a certain element to do something script-related, like bounce around the screen or something. Instead of linking to an external Javascript (js) file or having an internal script within a script element in HTML, this just uses htc files, which I’ve never used and never intend to use because it’s all Microsoft-specific (though other browsers do use it, most don’t).
Do yourself a favor, download, learn, and use jQuery if you want to use CSS selectors to define behavior in a WAY easier way that takes up less space and isn’t so abusive.
Stay away from the CSS behavior property. I mean if you wanna try it, go ahead. Just saying, it’ll most likely be a waste of your time.
Check out this page: http://www.w3schools.com/Css/css_dont.asp (hopefully the preceding link has shown up). The code shown there gives you the ability to make a working demonstration if you’re curious. Other than plain curiosity, I don’t see any use for such a property that cuts off what’s turning into half of browser users. And if you’re making an IE-specific site, like one of those university deals, don’t use it then either. jQuery works on just about every browser made in this decade.
Javascript within CSS is not CSS, just like copying random text into an HTML file is not HTML.
Hi,
how to implement this?
This is an IE propietary property not a CSS one
http://msdn.microsoft.com/en-us/library/ms530723%28VS.85%29.aspx
and here the w3 alternative option:
http://www.w3.org/TR/xbl/
img,
div {
behavior: url(templates/iepngfix.htc)
}
there are some *.htc files in the web, they normally do a “fix” to the behavior in IE for some image properties (e.g. transparency)
I remember a few years back when everyone complained that Microsoft were causing problems by using their proprietary attributes etc. and here we are using it again. :)