css 3

Icon

A comprehensive CSS 3 reference guide, tutorial, and blog
Are you a CSS expert? Want to contribute? Contact us

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.

 

15 Responses

  1. Jim says:

    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.

  2. Masum says:

    nice post. i like that…

    How can i use it. and when should i use it?

  3. Gautam Bhatia says:

    Hello,
    Are there any working example of this property so that we can actually see it implementation in realtime.

  4. Vivek says:

    hi
    How can i use it. and when should i use it?
    where is hilight.htc file

  5. AWDThomas says:

    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.

  6. Omar says:

    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.

  7. Josh says:

    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.

  8. Santanu says:

    Hi,

    how to implement this?

  9. Jorge says:

    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)

  10. Dwight Stegall says:

    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. :)

  11. Ibrahim Levent says:

    We used HTC for Date and Number input text fields for auto-formatting. Additionally, some input fields needs to have AJAX behaviours and HTC is best for this. For button push effect, we used it. You simply declare CSS behaviour in your style definion and use it: class=”myRichNumberInputText”

  12. Rakesh Pandey says:

    hi
    How can i use it. and when should i use it?
    where is hilight.htc file

  13. [...] CSS3 PIE is a behavior plug-in, proprietary to IE, that sits beside your stylesheet adding support for the following [...]

  14. raj says:

    Hello,
    Are there any working example of this property so that we can actually see it implementation in realtime.

Leave a Reply

Pages

Sponsors

$100 PSD to XHTML. CONTACT US FOR MORE INFORMATION


CSS3.com



Please help CSS3.com stay alive and running

Bad Behavior has blocked 973 access attempts in the last 7 days.