Last Updated: February 25, 2016
·
1.05K
· helmedeiros

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>

1 Response
Add your response

This website show all levels > http://cssspecificity.com/ Pretty good!

over 1 year ago ·