CSS Specificity
Specificità CSS
La specificità CSS è il peso di un selettore. Quando altre regole di cascade sono in parità, il browser usa questo peso per scegliere quale stile prevale.
Un altro esempio
`:where(.card)` ha zero specificità, mentre `.checkout .card.selected` ne ha di più. Un token del tema può sostituire pulitamente la regola base a basso peso. Un selettore ID di terze parti viene posizionato in un layer invece di combatterlo con un selettore ancora più lungo.
Parti principali
- 01colonna ID
- 02Colonna classe/attributo/pseudo-classe
- 03Colonna tipo/pseudo-elemento
Usalo quando
Mantieni i selettori dei componenti leggeri quanto necessario. Se uno stile non si applica, controlla la cascata calcolata del browser.
Non usarlo quando
Non correggere la struttura CSS con ID, classi ripetute o `!important` ovunque.
Nome usato nel codice
selector specificity tuple; :where() contributes zero Prima di spedire
Check content order, shared design values, component consistency, contrast, zoom, and layout changes by screen size. Verify every theme, language, and state. If there is motion, offer an equal reduced-motion experience.
Outcome: Complete the task with Specificità CSS (CSS Specificity). User context: `:where(.card)` ha zero specificità, mentre `.checkout .card.selected` ne ha di più. Un token del tema può sostituire pulitamente la regola base a basso peso. Un selettore ID di terze parti viene posizionato in un layer invece di combatterlo con un selettore ancora più lungo. Design concept to apply: Specificità CSS (CSS Specificity). Why it fits: Mantieni i selettori dei componenti leggeri quanto necessario. Se uno stile non si applica, controlla la cascata calcolata del browser. Do not use it when: Non correggere la struttura CSS con ID, classi ripetute o `!important` ovunque. Design requirements: Set the content order, shared design values, and reusable components. Define how the layout changes by screen size and state. Keep useful design choices separate from decoration. Inclusion and resilience: Check contrast, zoom, languages, themes, and reduced motion when needed. Do not use color or effects as the only way to show meaning. Acceptance criteria: The design stays clear on phones and desktops, at zoom, in every theme, and in all supported languages. Interactive states stay clear and consistent. Evidence and limits (evidence boundary): Un documento formale può ancora essere una bozza, un release candidate o la versione finale. Controlla il suo stato e il supporto per browser o piattaforma. Unknowns to confirm: Brand limits, amount of content, supported themes and languages, target devices, and design-system rules.
Controlla questa richiesta
Review how Specificità CSS (CSS Specificity) is used now. Definition: La specificità CSS è il peso di un selettore. Quando altre regole di cascade sono in parità, il browser usa questo peso per scegliere quale stile prevale. Release checks: Check content order, shared design values, component consistency, contrast, zoom, and layout changes by screen size. Verify every theme, language, and state. If there is motion, offer an equal reduced-motion experience. Before changing code, list the evidence, gaps, severity, and the smallest safe fix.