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

Why does document.querySelector('[title = label]') gives me a null in the console

I followed Guil as aways and the console keeps returning a null for document.querySelector('[title=label]') I'm not sure why ..

Thanks in advance for any help.

2 Answers

Hi Sandra!

I typed this into the index.html file (just like Guil did):

<p title="label">Things that are purple:</p>

And this in the console:

> document.querySelector('[title=label]');

And the console returned:

<p title="label">Things that are purple:</p>

So I'm not sure what is causing your issue...

Make sure you are not trying to type "document.querySelector('[title=label]')" in the workspace console. You have to preview index.html in the browser and right-click to inspect to get the dev tools and then use the dev tools console tab.

I hope that helps.

Stay safe and happy coding!

Highly possible that you might haven't specified attribute, title in the p element.