Use of !important limits the options for CSS customization

Use of !important limits the options for CSS customization

oleonardoleonard Posts: 6Questions: 2Answers: 0

https://codepen.io/oleonard/pen/mdNGNyK

There are several places in the base DataTables CSS where !important is used. Elements which are styled with !important cannot have those properties overridden by custom CSS. The only other option is to modify the default DataTables CSS, which can make upgrading more difficult.

In the example above I've added CSS to try to customize the style of the paging buttons. I am able to override the style of the "current" button's background but not the color of the text. The hover state can't have its background color or text color overridden.

Is !important really necessary?

Replies

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin

    It isn't necessary as such - it could be replaced with more selective statements. I am trying to remove them as I go around doing various house keeping tasks. In many cases they help keep the CSS smaller, but I do recognise that they can be annoying.

    I'm slowly moving things over to CSS variables which makes colour customisation much easier. I had thought I'd done that already for the paging buttons, but apparently not. Added to the list!

    Allan

Sign In or Register to comment.