CSS Combinators

Next ❯Pseudo Classes

Used to select the elements you want to style

  • turned_in_notCombinator Selectors
    • descendant selector [space]
    • child selector [>]
    • adjacent sibling selector [+]
    • general sibling selector [~]

descendant selector [space]

It selects all elements that are descendants of a specified element

/*Syntax*/

specified_Selector select_Selector{
  /*css properties*/
}

*descendant: can be child, grand-child, grand-grandchild and so on

<div>

   <p> I am inside div</p>

</div>
<div id="test">

   <p> I am inside div_id_test</p>

</div>

child selector [>]

It selects all elements that are the direct child of a specified element

/*Syntax*/

specified_Selector &gt; select_Selector{
  /*css properties*/
}
<div>

   <p> I am inside div</p>

</div>
<div id="test">

   <p> I am inside div_id_test</p>

</div>

adjacent sibling selector [+]

It selects all elements that are placed immediately after a specified element

/*Syntax*/

specified_Selector + select_Selector{
  /*css properties*/
}
<div></div>

<p>Hello my friends!</p>

<div id="test"></div>

<p>Good Luck !</p>

<p>Well Done !</p>


general sibling selector [~]

It selects all elements that are siblings of a specified element and declared after it

/*Syntax*/

specified_Selector ~ select_Selector{
  /*css properties*/
}

*siblings: Sharing same parent

<p>Well Done !</p>

<div></div>

<p>Hello my friends!</p>

<div id="test"></div>

<p>Good Luck !</p>

<p>Well Done !</p>


  • Pseudo Classes
❮ Prev CSS Counter
Next ❯Pseudo Classes
TryOut Examples"Learn to Explore..!"

TryOut Editor

receipt