Nested Selectors
By default nested elements automatically inherit parent styles, but sometimes we expect a different behavior from nested elements.
On those cases is very important to know the specificity rule(the priority of selectors). Think os specificity as four digits number, where the lowest values are in the amount of elements selectors (a, p, img, div, etc); and the highest values are in the inline selectors. ex.:
0,0,0,1
p { color: #fff; }
0,0,1,0
.intro { color: #98c7d4; }
0,1,0,0
#header { color: #444245; }
1,0,0,0
<h1 style="color: #000;">Mogul</h1>
Written by Hélio Cabral Medeiros
Related protips
1 Response
This website show all levels > http://cssspecificity.com/ Pretty good!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#