Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS: !important est vraiment à proscrire #22

Open
YannisDelmas opened this issue Feb 2, 2022 · 2 comments
Open

CSS: !important est vraiment à proscrire #22

YannisDelmas opened this issue Feb 2, 2022 · 2 comments

Comments

@YannisDelmas
Copy link
Owner

YannisDelmas commented Feb 2, 2022

Universellement reconnu comme une mauvaise pratique: il FAUT s'en passer quand c'est possible, c'est à dire presque toujours.

https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

@YannisDelmas
Copy link
Owner Author

"By default, rules in author style sheets have more weight than rules in user style sheets. Precedence is reversed, however, for "!important" rules. All user and author rules have more weight than rules in the UA's default style sheet." [CSS 2.1, §6.4]

L'objectif est: "CSS attempts to create a balance of power between author and user style sheets." [CSS 2.1, §6.4.2] Donc, l'usage de "!important" devrait être limité aux feuilles de style utilisateur, donc aux dispositifs d'accessibilité.

@YannisDelmas
Copy link
Owner Author

Justifications pratiques:

  1. ça rend la maintenance difficile: très dur à surcharger.
  2. ça casse les règles de spécificité

@YannisDelmas YannisDelmas changed the title CSS : !important est vraiment à proscrire CSS: !important est vraiment à proscrire Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant