cosmichero2025
cosmichero2025

Reputation: 1029

Can you set the attribute !important to multiple css values at once?

Could you do something like this? I've looked around and couldn't find anything.

!important {
footer {
    color: white;
}
.socialNetwork li {
    list-style-type: none;
}
.bar {
    background: white;
    height: 10px;
    width: 550px;
    margin-top: 25px;
    margin-bottom: 20px;
}
}

Upvotes: 1

Views: 69

Answers (2)

Matt S
Matt S

Reputation: 15374

No, because !important is not a selector. Also see the advice on MDN:

Using !important is bad practice and should be avoided because it makes debugging more difficult by breaking the natural cascading in your stylesheets. When two conflicting declarations with the !important rule are applied to the same element, the declaration with greater specificity will be applied. ...

  • Always look for a way to use specificity before even considering !important
  • Never use !important on site-wide CSS

Instead, you'll want to review the order of the CSS you are setting, and then see how they cascade, overriding as needed.

Upvotes: 3

B. Pereira
B. Pereira

Reputation: 75

I don't know the reason why you trying to do this, but this syntax or similar doesn't exist.

Using !important in everything isn't good either, see details about it in this post.

Upvotes: 0

Related Questions