core error

!important in CSS

Posted on: 14/09/2011


!important declared after a CSS directive ensures that directive is applied preferred over other styles for the same locator no matter if the former is preceding the later or not.


if you are combining several CSS files in a webpage you may need to have to define two or more different styles for the same locator. For these cases, by using the rule !important you can ensure that style is applied over other conflicting styles for the same element/s.


Here is a simple example to ilustrate how to use this rule:

p { color: #ff0000 !important; }
p { color: #000000; }

In this example all the <p> elements affected by this stylesheet will have a red color for the text inside instead of black.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


  • None
  • Justin Cooney: Great comic, this made me laugh!
  • Justin Cooney: Interesting, I didn't know about the Google App Engine, I'm glad I found your article on it!


%d bloggers like this: