user2238214
user2238214

Reputation: 605

Overriding CSS for ::selection back to browser defaults

I've got a site in which I'm dealing with a CSS specification that I want to override. One of the things it specifies is a background and color for the ::selection property.

I can override these with other explicitly defined backgrounds and colors, but that's not really what I want. What I want is just to be able to revert to the browser defaults: to let Safari, Chrome, Firefox, etc., just do whatever they'd normally do (e.g., Safari uses a light blue background, but I'd rather not hard-code that).

What's the best way to do this?

Upvotes: 2

Views: 270

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191729

Due to how CSS works in the cascade, there is no way to revert styles on a particular element. Styles from the User Agent declarations have lower precedence than all other declarations, and the ability to revert rules does not exist. The only solution is to get rid of those styles in the first place (although I can understand how that may be difficult), hard code the necessary styles, or choose yet another style that at least looks okay.

Upvotes: 3

Related Questions