!important use case
Hey, if i would like to hide an element on mobile and use a utility class along the lines of:
however the element i would like to hide, let's say it's a button, has some styling that overrides the
display: none
due to it having a higher specificity, causing it not to hide on mobile, for example:
would it be an acceptable case to use !important
on the hide-mobile
utiliity class? Or would it require another solution? Many thanks.6 Replies
yess, !important should do the trick
awesome, thank you. would you say it's a valid use case? i know people recommend to avoid using it as it causes problems long term, but for a class like this where it should occur no matter what and
important
isn't being used to fix or cover up another problem, i imagine it's okay? i could be wrong.i still have a lot to learn but in this case i would use it, yes. if feel like if you end up using !important multiple times for roughly the same thing it would get complicated indeed, but in your current scenario it will only be used once for this specific thing
Yeah that’s what I was thinking, I appreciate your insight, and good luck on your learning journey!
good thinking :), youre welcome! thanks a lot! you too :)
Thanks! 🙏🏻