Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Getting a Handle on the DOM Using CSS Queries to Select Page Elements

querySelectorAll(' '); While writing this we need css selectors and why do we need > to refer to the child of the elemen

for example querySelectorAll(' #nav > p'); > why do we use this thing in js to refer to child of the nav id, while we don't use it when we are writing in css?

2 Answers

You can use it in CSS as well. > is for a direct child, but just a space is for any descendant.

This SO thread might help.

thanks bro, now it's clear