How is the CSS attribute property !important read?
Is it really important, exclamation mark important, …?
Answer: From the answers below, it seems to be read simply important, or bang important.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
http://www.w3.org/TR/CSS2/cascade.html#important-rules
Basically, where two style rules are the same… it gives the one marked
!importantgreater importance and will apply those styles.Example
The first rule would be applied even though the second rule is more specific (one element + one class as opposed to one element)
Note: IE6 ignores
!importantwhen you have two of the same property and one of them is important – it’ll always apply the last declaration, whether or not it was marked important. **Added from @BoltClock‘s comment below.Warning:
!importantis a hammer that should only be used when absolutely necessary. Almost always, it is better to use more specific selectors to achieve greater specificity and have your styles applied the way you want.!importantcan make it very difficult for future developers to find and make changes to your code.One good use case:
!importantis great for user-defined styles, where a user wants to manipulate Web site pages in specific way in his browser (say make all the backgrounds black and the text yellow). Without having to worry about specificity, the user can add styles to certain elements (likebody) and make the styles render.