Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Created December 16, 2022 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nocodesupplyco/08eb06a80b37670be637c5f068094b3a to your computer and use it in GitHub Desktop.
Save nocodesupplyco/08eb06a80b37670be637c5f068094b3a to your computer and use it in GitHub Desktop.
Common CSS Combinators
/* 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