Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Is it possible to ignore a specific style on style sheet for a specific page? Re: Is it possible to ignore a specific style on style sheet for a specific page?

#124331
__
Participant

@Dami – do you need to support IE < 9?


You can polyfill earlier versions of IE, of course, but I don’t know that you’d want to depend on js for this.

If it’s possible, I’d still recommend (working with a backup copy, of course) adding a class name to all the special-style inputs. A good text editor will allow you to make the changes with a [regex] search-and-replace so you don’t have to do it manually. How this works would depend on your editor, and on your existing markup.

*****

> @traq Oo? You are talking like someone will die. :) It’s not that big deal to use ID to override some rule. Actually in this specific situation is far better to do so than to add probably 20+ class attributes in HTML.

No, no lives at stake. I maintain, however, that it is not a preferable solution.


@Dami
is dealing with the difficult situation of working with someone else’s code, that was not well designed. The goal should be to *fix* the code where possible, rather than adding more confusion on top of existing problems.

Creating a new rule with higher specificity will work, of course, but it makes everything more fragile – what happens if, later on, they want to change the font/border/whatever on *all* (yes, really all of them, this time) input elements? If they put the rule into the existing style rule, it might not affect the input(s) with the overridden styling. So, you’d have to write two selectors (existing input, overridden input) to apply the new styling. And same thing next time, except maybe four new selectors/rules.

This is likely how the problem came to be in the first place. It _would_ be preferable (maybe not _practical_) to add those 20+ class attributes.

Since you have to make *some* changes, I’d recommend making changes that will make things easier on you (and your coworkers/successors) in the future.