Remove/reset CSS behavior property
Asked Answered
A

3

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.

Aesop answered 22/12, 2010 at 21:7 Comment(1)
It makes no sense to mark this as a duplicate. It pre-dates the other question, has more detail, and more people involved.Aesop
A
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;
}
Aesop answered 24/12, 2010 at 14:38 Comment(4)
I found an empty string worked as well (at least in IE8), but it looks like the default value is actually none, see here: #7953947 I'm sorry the answers you got were so bad.Bestride
nice solution, doesn't seem to work for color though, does anyone have any solutions for that use case?Hendeca
A "none" color doesn't really make sense. Would it be black? White? Transparent?Gyno
It's 'transparent' if you are trying to change background-color.Lymph
D
-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

Donata answered 22/12, 2010 at 23:20 Comment(0)
B
-8

Maybe use conditional tags for IE in your head

<!--[if IE]>
<style type="text/css">
    .a-rule {
       behavior: url(/some.htc);
    }
</style>
<![endif]-->
Become answered 22/12, 2010 at 21:16 Comment(1)
There is no such syntax in stylesheets.Demonolater

© 2022 - 2024 — McMap. All rights reserved.