core error

!important in CSS

Posted on: 14/09/2011


What

!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.

Why

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.

How

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.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s


    • 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!

    Categories

    %d bloggers like this: