CSS Selectors
Enter selectors (one per line) to compare.
1
Specificity Ranking
Inline (1,0,0,0)
ID (0,1,0,0)
Class/Attr/Pseudo (0,0,1,0)
Element (0,0,0,1)
!important
Enter CSS selectors and click Analyze to see specificity comparisons.
Specificity Quiz
Test your CSS knowledge. Which selector will win?
Score: 0/0
Streak: 0 🔥
<div id="hero" class="banner
primary">
Hello World
</div>
Hello World
</div>
Which selector has higher specificity?
How is CSS Specificity Calculated?
Inline Styles
Styles applied directly to an element via the style attribute.
<div style="color: red;">
IDs
ID selectors match elements with the specified ID.
#header, #hero-btn
Classes, Attributes & Pseudo-classes
Class selectors, attribute selectors, and pseudo-classes.
.button, [type="text"], :hover
Elements & Pseudo-elements
Type selectors and pseudo-elements.
h1, div, p, ::before
The Override Rule
An !important declaration overrides normal specificity, except against
another !important with higher specificty.
color: red !important;
Ignored Selectors
The universal selector (*) and combinators (+, >,
~, ) have no effect on specificity.
*, body > p