---
title: "!important Rules in stylesheet"  
description: "In this blog I am trying to explain the concept of !important rules in stylesheet.!important Rules:Along with the need for the cascade in CSS came the"  
author: "Vijay Shukla"  
published: 2013-06-17  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/538/important-rules-in-stylesheet  
category: "css-css3"  
tags: ["css-css3"]  
reading_time: 2 minutes  

---

# !important Rules in stylesheet

In this blog I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to [explain the concept](https://www.mindstick.com/forum/159605/explain-the-concept-of-unique-key-violation-error) of !important rules in stylesheet.

!important Rules:

Along with the need for the [cascade](https://answers.mindstick.com/qa/116301/what-is-cascade-in-sql) in CSS came the need to override it. This is where !important rules come in. The !important syntax appears within a declaration, after the [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) value and before the semi-colon that terminates the declaration. [Two components](https://www.mindstick.com/forum/161485/how-does-a-generative-adversarial-network-gan-work-explain-its-two-components) make up this syntax; an exclamation mark, used here as a delimiter, and the important [keyword](https://www.mindstick.com/forum/33572/sql-inner-join-keyword). A delimiter marks the ending of the thing and the beginning of another. Here the exclamation mark singles the end of the declaration. The important keyword must appear next, followed by a semicolon to terminate the declaration;

##### Example code: -

##### 1. Enter the following markup into your text editor:

```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>    <title>Mindstick Demo By Vijay Shukla</title>    <style type="text/css">        body        {            font: 14px sans-serif;
        }        span#precedence        {            background: lightyellow;
        }        span        {            background: orange !important;
        }
    </style>
</head><body>    <p>
        !important rules are used to override specificity. The !important syntax causes
        a selector to have<span id="precedence"> greater oprecedence than those without it.
        </span>It also <span style="background: lightblue;">has greater precedence than the
            (X)HTML style attribute</span>    </p>
</body>
</html>
```

2. Save the preceding document.

3. Run the demo.

##### Output: -

![!important Rules in stylesheet](https://www.mindstick.com/blogs/e53fcce4-f069-4bdf-8548-ea5a1fbcc1a2/images/44d5d333-d222-427c-9cfc-4238d6260426.png)

##### How it works:

In this demo you see how the !important rule overrides precedence. Because the following declaration contains the !important systax, it causes the background of all the <span> elements to be orange.

```
span{     background: orange !important;
}
```

---

Original Source: https://www.mindstick.com/blog/538/important-rules-in-stylesheet

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
