You can outweigh any specificity of other declarations in CSS by setting !important
after the value. Overriding this is only possible with another declaration with !important
.
.hovertest:hover {
background-color: black !important;
}
#hovertest:hover {
background-color: red; /* Even using an ID won't override `!important` */
}
But be careful! Using !important
in your CSS can result in some really tricky issues. It's often more useful to write your CSS in a way where you avoid using it as much as possible.
Don't use !important
reactive, use it preventive.