Why is a second-child affected by my first-child color property?

后端 未结 4 1442
野性不改
野性不改 2021-01-16 21:47

I was finishing up selectors and testing my knowledge and encountered a problem that makes no sense.

In theory, the code below should color all first children that

4条回答
  •  囚心锁ツ
    2021-01-16 22:24

    color is inherited from the parent element....in this case the li:first-child

    So when you tell the li to be a red color this is inherited by all its children.

    You have no rule to override this for the children so they are colored by inheritance/

提交回复
热议问题