-
-
Save nocodesupplyco/08eb06a80b37670be637c5f068094b3a to your computer and use it in GitHub Desktop.
Common CSS Combinators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Descendant Selector */ | |
/* Matches all elements that are descendants of a specified element. */ | |
.box p { | |
color: red; | |
} | |
/* Child Selector */ | |
/* A greater-than symbol (>), which matches only when the selectors select elements that are direct children. Descendants further down the hierarchy don't m*/ | |
.box > p { | |
color: red; | |
} | |
/* Adjacent Selector */ | |
/* Used to select something if it is right next to another element at the same level of the hierarchy. */ | |
.box + p { | |
color: red; | |
} | |
/* General Sibling Selector */ | |
/* If you want to select siblings of an element even if they are not directly adjacent, then you can use the general sibling combinator (~). */ | |
.box ~ p { | |
color: red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment