مُحسب تخصيص CSS
مرشد
مُحسب تخصيص CSS
The CSS Specificity Calculator helps you determine the exact specificity score of any CSS selector. Understanding specificity is crucial for debugging CSS conflicts and writing maintainable stylesheets. Enter one or more selectors and instantly see their (a,b,c) scores compared side by side.
كيفية استخدام
Enter one CSS selector per line in the input field. The tool will automatically calculate and display the specificity score for each selector. When multiple selectors are entered, the one with the highest specificity is highlighted in green so you can quickly see which rule wins.
خصائص
- W3C-Compliant Scoring – Calculates specificity using the official (a,b,c) algorithm: IDs, classes/attributes/pseudo-classes, and elements/pseudo-elements.
- Multi-Selector Comparison – Enter multiple selectors to compare their specificity scores and see which one wins.
- CSS Selectors Level 4 – Supports modern pseudo-classes like :is(), :not(), :has(), and :where() with correct specificity handling.
- Visual Score Display – Color-coded score badges and proportional bars make it easy to understand specificity at a glance.
- معالجة جانب العميل – All calculations happen in your browser. No data is sent to any server.
التعليمات
-
What is CSS specificity and how is it calculated?
CSS specificity is a weight system that determines which CSS rule applies when multiple rules target the same element. It is calculated as a three-part score (a,b,c): a counts ID selectors, b counts class selectors, attribute selectors, and pseudo-classes, and c counts type selectors and pseudo-elements. A higher score in an earlier position always wins regardless of later positions.
-
How do :is(), :not(), and :has() affect specificity?
According to CSS Selectors Level 4, the specificity of :is(), :not(), and :has() pseudo-classes is equal to the specificity of the most specific selector in their argument list. For example, :is(.foo, #bar) has the specificity of #bar (1,0,0) because it is the most specific argument. The :where() pseudo-class is the exception — it always contributes zero specificity.
-
Does the order of CSS rules matter when specificity is equal?
Yes. When two selectors have exactly the same specificity score, the CSS cascade rule applies: the rule that appears later in the source code wins. This is why understanding specificity is important — relying on source order alone can lead to fragile stylesheets that break when rules are reordered.
-
Why does an ID selector override multiple class selectors?
The specificity algorithm compares scores position by position from left to right. An ID selector scores (1,0,0) while any number of class selectors only increase the second position. Since position a is compared before position b, even a single ID selector will always override any combination of class, attribute, or pseudo-class selectors, no matter how many there are.
تثبيت ملحقاتنا
أضف أدوات IO إلى متصفحك المفضل للوصول الفوري والبحث بشكل أسرع
恵 وصلت لوحة النتائج!
لوحة النتائج هي طريقة ممتعة لتتبع ألعابك، يتم تخزين جميع البيانات في متصفحك. المزيد من الميزات قريبا!
