Wikia

!important

Talk0
645pages on
this wiki

The CSS !important declaration is used to specify which style to rule. Property values with this declaration following them will override other existing property values of similar effect.


Example:

<style type="text/css">
    p { 
       color:green !important;
}
</style>
<p style="color:red;">This text will be green.</p>

Normally the color of the text would be red, because inline styles override the rules set in a <style> element. By including the !important declaration in the style rule, you set the content of the paragraph to green.


More examples:

In a CSS file...
h1 {
    color:white !important;
}
In the HTML file...
<head>
   <link rel="stylesheet" type="text/css" href="CSS.css" />
</head>
<body>
   <h1 style="
     color:orange !important;
   ">TEXT</h1>
</body>

The text in the first heading will be orange, even though the CSS specified it as white with the important declaration, because the orange color in the <h1> element itself is marked with the important declaration, resulting in orange text instead of white text.

External LinksEdit

Advertisement | Your ad here

Photos

Add a Photo
233photos on this wiki
See all photos >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki