33

Is it possible to remove the IE-specific behavior CSS property via a more specific rule or the !important declaration? Example:

.a-rule
{
  behavior: url(/some.htc);
}
.a-rule.more-specific
{
  behavior: /*no HTC*/
}

I realize that overriding CSS properties is undesirable, but I'm stuck here.

On Edit: I'm not sure where people are getting confused about this question. For all purposes, you can consider this already being an IE specific stylesheet. I'm asking how, if .a-rule above exists and is immutable, how can one remove the behavior via a more specific rule? A standard CSS equivalent would be:

.a-rule
{
  border: 1px solid black;
}
.a-rule.more-specific
{
  border: 0 none;
}

One can reset the border property for a subset of elements via a more specific rule. I'm asking how to reset the behavior property in an analogous way.

Jeremy Kauffman
  • 10,293
  • 5
  • 42
  • 52

3 Answers3

42

The default value is "none". See:

What is the *correct* way to unset the behavior property in CSS?

The solution:

.a-rule
{
  behavior: url(/some.htc);
}
.a-rule.more-specific
{
  behavior: none;
}
Community
  • 1
  • 1
Jeremy Kauffman
  • 10,293
  • 5
  • 42
  • 52
  • 3
    I found an empty string worked as well (at least in IE8), but it looks like the default value is actually `none`, see here: http://stackoverflow.com/questions/7953447/what-is-the-correct-way-to-unset-the-behavior-property-in-css I'm sorry the answers you got were so bad. – Wesley Murch Oct 31 '11 at 21:13
  • nice solution, doesn't seem to work for color though, does anyone have any solutions for that use case? – Mike H-R Nov 19 '13 at 11:10
  • A "none" color doesn't really make sense. Would it be black? White? Transparent? – kand Feb 11 '14 at 19:45
  • It's 'transparent' if you are trying to change background-color. – pherris Apr 04 '14 at 19:52
-5
.a_rule {
  border: 1px solid black; /* we know border is black */
  behavior: url(/some.htc) /* we know something happen inside some.htc */
}
 .a_rule.more-specific {
  border: 0 none; /* we remove the border */
  behavior: url(/some.htc) /* we remove something inside some.htc */
}

use different .htc file

haha
  • 1,522
  • 2
  • 15
  • 18
-8

Maybe use conditional tags for IE in your head

<!--[if IE]>
<style type="text/css">
    .a-rule {
       behavior: url(/some.htc);
    }
</style>
<![endif]-->
Cole
  • 740
  • 5
  • 8