Adding !important into your css tells the browser that, no matter what happens keep this always. Say you clear something with I only use it when overriding ajax styles or remote styles. The !important directive is helpful when you are testing and debugging a website. Why you should avoid using !important in your CSS. It means that if we have a website element, let’s say a “title”, and we want to make the text size “20px”, the color “black”, and the padding around it “10px”, we would use CSS to control the look of our element. The overriding !important rule should be declared lower on the CSS flow and it should have the same or higher level of specificity in order to be in effect.This is how the CSS !important rule works and hopefully this post will help you in deciding where to use it and where not to use it.Get your team upskilled or reskilled today. The only way we can override the color of our

element now is with additional !important tags that are applied later in our CSS.As mentioned, each CSS selector carries a different “weight.” Browsers use to this weight to determine which styles should have priority. It’s easy and often perfectly valid to write a CSS selector that has a higher specificity value than 0,0,1,0 and accidentally screws up a button. The weight is represented by a calculated specificity score between 0.0.0.0.0 and 1.0.0.0.0.In the chart above, we can see the least specific (0.0.0.0.0) selector to most specific (1.0.0.0.0) selector. I sat here for hours trying to get the background of an text input field to be transparent in IE 7 and it just wouldn’t play ball. This is the first attempt:Despite declaring a normal font-style specifically for the element, the text is still italicized.Under normal circumstances, this would override the font-style that is set for the element, but it’s not working as expected!The developer may even try adding a class or an ID to the element, only to discover that nothing will override the italicized text.At this point, the only option is to add an !important tag to force the style to apply.The only thing that can override an !important tag is another !important tag. Although we have not gone into the details of using CSS (that is well beyond the scope of this article), we hope that you have a better understanding of why it’s important. Using !important in your CSS usually means you’re narcissistic & selfish or lazy. In fact, it’s strongly recommended that you avoid using the !important tag in the vast majority of cases. In this case, styles that are declared specifically for child elements will override the inherited styles of their parent elements.With CSS we have the ability to “select” our HTML in a variety of ways. However, in this particular case we want to keep our navy font color.This will only target the text inside the content div and increase our specificity value to 0.0.1.2.0.Option 2: We can introduce a “text-red” modifier class to the second

element.This will keep our specificity value to 0.0.0.2.0, but still solve our problem.Both options 1 and 2 will achieve the desired result:As you can see, when you’re styles aren’t “working like they’re supposed to” you don’t have to resort the !important tag. Go ahead and grab a cup of coffee and prepare for some code examples.When you’re just starting with CSS, the !important tag seems like a secret weapon that you can pull out when styles aren’t working as expected. The problem in this case is the “#content a” declaration as it’s the one that messes things up and should be avoided. Links in those containers can then be styled differently from the rest of the page using “.sidebar-box a { … }”. In the example below, the font-size of the paragraphs is overridden by !important rule in the first declaration, even though the second declaration should have been in effect considering the natural flow of CSS.Initially, the !important rule was introduced for use in user style sheets as a means for providing the ability to the user to modify the style of a web page to fit their needs (e.g. Since so many people don't know proper CSS architecture, many people just tell you not to use it in order to make your CSS life easier.