What is the use of "!important" in css? [SOLVED] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 23

What is the use of "!important" in css? [SOLVED]

Please explain what is the difference between line 1 and line 2 line 1: display:block!important; line 2: display:block; why and where do we use "!important" ?

3rd Nov 2018, 4:54 PM
Suraj Jha
Suraj Jha - avatar
13 Answers
+ 6
In simple words !important in any css gives it prior importance.
4th Nov 2018, 12:06 PM
Anshul Riyal
Anshul Riyal - avatar
+ 6
Suraj the most important behaviour of ‘!important’ rule are 1. overriding INLINE styles on elements which are not have ‘!important’ in them. 2. the second use is to override long chains in selectors. so so as solution as code 3. the third is override partucular rules in case of classes that are responsible for behaviour. as example .hide {display: none!important} to be sure that element will be defenitely hidden also in case of overwritten display property etc
4th Nov 2018, 7:20 PM
Sergei No
Sergei No - avatar
+ 5
A helpful question. Thanks a lot.
11th Feb 2019, 9:17 PM
FirstSoloKiller
FirstSoloKiller - avatar
+ 4
don’t use it, it causes a lot of problems, organize your code instead.
4th Nov 2018, 10:10 AM
Sokrat_Poghosyan
Sokrat_Poghosyan - avatar
+ 3
Lets say we have a code of Css: “div.Div1 { display: none; display: table !important “ Then Instead of “display: none” it will do the Most Important one(!important) one “display: table !important”.
4th Nov 2018, 9:26 PM
Potato Hacker
Potato Hacker - avatar
+ 1
Here is the style rule code: https://code.sololearn.com/Wpjo8QJIXtVy/?ref=app You can do different things than this.
5th Nov 2018, 1:15 AM
Potato Hacker
Potato Hacker - avatar
+ 1
It makes the style over any other is on the selector.
6th Nov 2018, 6:45 PM
David Perez
David Perez - avatar
0
Lexus Collins, is it possible that browser could ignore line 2?
3rd Nov 2018, 5:03 PM
Suraj Jha
Suraj Jha - avatar
0
Lexus Collins, Thank !! I got this 😊😊😊
3rd Nov 2018, 5:16 PM
Suraj Jha
Suraj Jha - avatar
0
привет всем
4th Nov 2018, 9:58 AM
Мадиярбек
0
yas
4th Nov 2018, 11:30 AM
Мадиярбек
0
yas
4th Nov 2018, 11:31 AM
Мадиярбек
- 2
I think it means "Not Important"!
3rd Nov 2018, 4:58 PM
Maksat Orazsahedow
Maksat Orazsahedow - avatar