What is "! Mportant" for in CSS?

Asked

Viewed 108 times

1

Several times I’ve seen this attribute or property (I don’t know exactly how to classify it), but I still don’t understand :

  • What is the need to use it ;
  • To which server extly ;
  • When to use it.

h4, .texto{
  
      color:white !important;
      text-align: center;
      font-size: 40px;
  
}

1 answer

2


Serves to override the already assigned css for the element, Example:

.corAzul{
background-color: blue !important; 
}

.corVerde{
background-color: green; 
}
<input type="text" style="background-color:red;" class="corAzul"/>
<input type="text" style="background-color:red;" class="corVerde"/>

As you can see in the example I have the classes corazul and corVerde being the blue as Important and the green not and inline I put to be red, No input1 it brings blue and the green he considers the inline, So how do you have the two identical Tyles for the same element with the !Important you tell the browser which it should consider.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.