Would it be a good idea for you to utilize !important in CSS ?

author details
AdiPie
24th Dec 2020
1 min read
Image
use of important

First, we discuss what is the use of !important in CSS. If you were not aware of the !important in CSS property.

!important plays a vital role to make a priority of the CSS property style. So, no chance to avoid to use this one.

If you try to override the style of your CSS class then you may add !important to your style. This facility is happening only for overriding in one or two places but if you use this for mostly styles then it may occur problem to you and you might be confused. Be aware to use !important in your style in CSS.

/* high specificity */

.main .header .nav { font-size: 2rem; }

/* will override the above, but it's dangerous! */

.header{ font-size: 3rem !important; }