mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
29 stars 17 forks source link

Remove "!important" CSS rules as much as possible #2732

Open singingwolfboy opened 7 years ago

singingwolfboy commented 7 years ago

It's possible to use !important on a CSS rule to override all other rules. This is bad practice, and should be avoided because it makes debugging CSS more difficult. (see MDN reference) It also makes it more difficult for user-specified styles to override website-specified styles, which can sometimes be important for accessibility purposes.

We should avoid !important whenever possible in our CSS. When it is not possible to avoid !important, we should add a comment justifying its use.

pdpinch commented 7 years ago

I don't disagree with the sentiment, but the way this is phrased this is an issue that can never be closed.

Do we have a lot of these? If its a manageable number, this issue should be to remove them all. If there are too many, we should break them off into bite-sized pieces.

Should this just be limited to the issue in https://github.com/mitodl/micromasters/pull/2693#discussion_r103716869 and the code it was copied from?

singingwolfboy commented 7 years ago
$ grep "\!important" static/scss/*.scss static/scss/public_style/*.css | wc -l
164

It's a lot -- more than I realized. Bite-sized pieces is probably a good idea.