Explain what elements will match each of the following CSS selectors:

Submitted 3 years, 6 months ago
Ticket #264
Views 594
Language/Framework CSS
Priority Low
Status Closed

  1. div, p
  2. div p
  3. div > p
  4. div + p
  5. div ~ p
Submitted on Oct 26, 20
add a comment

1 Answer

Verified

div, p : Selects all <div> elements and all <p> elements

div p : Selects all <p> elements inside <div> elements

div > p : Selects all <p> elements where the parent is a <div> element

div + p : Selects all <p> elements that are placed immediately after <div> elements

p ~ ul : Selects every <ul> element that are preceded by a <p> element

Submitted 3 years, 6 months ago

For the "div~p" is it to select every <p> element that are preceded by a <div> element? , I kinda guessed using the last point you noted..

- kanagasabai 3 years, 6 months ago


Latest Blogs