Six selector groups listed from highest to lowest priority: : Selector priority « Style Basics « HTML / CSS






Six selector groups listed from highest to lowest priority:

 

1. group contains rules with !important.  
2. group contains rules embedded in the style attribute. 
3. group contains rules that have one or more ID selectors. 
4. group contains rules that have one or more class, attribute, or pseudo selectors.
5. group contains rules that have one or more element selectors. 
6. group contains rules that have only a universal selector.
 

 








Related examples in the same category

1.Selectors choose the element to apply formatting to
2.Specificity means that more specific selectors are given priority over less specific selectors
3.Style is overwritable
4.Cascade Order
5.select elements by type, class, and/or ID
6.Specificity, !important
7.!important has higher priority
8.Latter one overwrite the former one
9.the id selector is more specific than the element selector
10.Some properties in CSS are inherited to children elements