css_guidelines:specificity
Differences
This shows you the differences between two versions of the page.
| css_guidelines:specificity [2016/08/10 16:57] – created leo | css_guidelines:specificity [2016/08/10 17:01] (current) – leo | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== Specificity ====== | ====== Specificity ====== | ||
| - | As we’ve seen, CSS isn’t the most friendly of languages: globally operating, very leaky, dependent on location, hard to encapsulate, based on inheritance… But! None of that even comes close to the horrors of specificity. | + | comme nous l' |
| - | No matter how well considered your naming, regardless of how perfect your source | + | Quels que soient les efforts que vous aurez mis dans votre nommage, aussi parfaite soit l' |
| - | The problem with specificity is that it sets precedents and trumps | + | Le problème avec la spécificité est qu'il établi des précédents et cartes (trumps |
| < | < | ||
| Line 13: | Line 13: | ||
| </ | </ | ||
| - | Not only does this exhibit poor Selector Intent—I didn’t actually want every table in the # | + | Non seulement cela montre une piètre |
| < | < | ||
| Line 24: | Line 24: | ||
| </ | </ | ||
| - | The first selector was trumping the specificity of the one defined after it, working against | + | Le premier sélecteur surpassait la spécifité de celui défini après |
| - | - refactor my CSS and HTML to remove that ID; | + | - refactorer mon CSS et HTML pour enlever cet ID ; |
| - | - write a more specific selector to override it. | + | - écrire un CSS plus spécifique pour overrider la première règle. |
| - | Unfortunately, refactoring would have taken a long time; it was a mature product and the knock-on effects of removing this ID would have been a more substantial | + | Malheureusement, la refactorisation aurait pris trop de temps, il s' |
| < | < | ||
| Line 37: | Line 37: | ||
| </ | </ | ||
| - | Now I have a selector that is even more specific still! And if I ever want to override this one, I will need another selector of at least the same specificity defined after it. I’ve started on a downward spiral. | + | J' |
| - | Specificity can, among other things, | + | La spécificité peut, entre autre choses : |
| - | - limit your ability to extend and manipulate a codebase; | + | - limiter votre capacité à étendre et manipluer une base de code; |
| - | - interrupt and undo CSS’ cascading, inheriting nature; | + | - interrompre et revenir sur la nature de la cascade |
| - | - cause avoidable verbosity in your project; | + | - causer une verbosité évitable dans votre projet; |
| - | - prevent things from working as expected when moved into different environments; | + | - empêcher mes choses de fontcionner comme prévu lorsque déplacer dans un environnement différent. |
| - | - lead to serious developer | + | - engendrer une sérieuse |
| - | All of these issues are greatly magnified when working | + | Tout ces problèmes sont grandement amplifiés lorsque l'on travaille sur un grand projet avec plusieurs développeurs contribuant au code. |
| ===== Keep It Low at All Times ===== | ===== Keep It Low at All Times ===== | ||
| - | The problem with specificity isn’t necessarily that it’s high or low; it’s the fact it is so variant and that it cannot be opted out of: the only way to deal with it is to get progressively more specific—the notorious specificity wars we looked at above. | + | Le problème avec la spécificité n'est pas nécessairement qu' |
| - | One of the single, simplest tips for an easier life when writing | + | Un des seuls et plus simples trucs pour se simplifier la vie en écrivant des CSS — en particulier à une taille raisonnable |
| - | Doing so will instantly help you tame and manage your project, meaning that no overly-specific selectors are likely to impact or affect anything of a lower specificity elsewhere. It also means you’re less likely to need to fight your way out of specificity corners, and you’ll probably also be writing much smaller stylesheets. | + | S'en tenir à cela vous aidera à maîtriser et gérer votre projet, signifiant qu' |
| - | Simple changes to the way we work include, but are not limited to, | + | des changement simples à notre manière de travailler incluent, mais ne se limitent pas à : |
| - | - not using IDs in your CSS; | + | ne pas utiliser d'ID dans votre CSS; |
| - | - not nesting selectors; | + | ne pas nicher de sélecteurs; |
| - | - not qualifying | + | ne pas qualifier les classes; |
| - | - not chaining selectors. | + | ne pas chaîner les sélecteurs. |
| - | Specificity can be wrangled and understood, but it is safer just to avoid it entirely. | + | La spécificité peut être discutée et comprise, mais il est plu ssimple de l' |
css_guidelines/specificity.1470841031.txt.gz · Last modified: 2016/08/10 16:57 by leo